Run Access Sub Routine from Excel

bconner

Registered User.
Local time
Yesterday, 20:38
Joined
Dec 22, 2008
Messages
183
I have an Access Db Module on another computer that contains a Sub Routine I would like to execute from Excel. How can I execute the routine and have it open and run on the host computer from an Excel workbook on my computer? I tried the code below but ran into two problems (1.) It opens the Access DB on my computer instead of the Host (2.) the appAccess.Run command didn't run the sub routine in Access



Code:
Sub RunAccessSub()
 
Dim appAccess As Access.Application
 
' Create instance of Access Application object.
Set appAccess = CreateObject("Access.Application")
 
 
' Open WizCode database in Microsoft Access window.
    appAccess.OpenCurrentDatabase "B:\Documents and Settings\bconner\Desktop\Template Month End Reports v1.2.mdb", False
 
 
 
' Run Sub procedure.
    appAccess.Run "MonthEndReports"
Set appAccess = Nothing
 
 
 
 
End Sub
 
I believe the Sub has to be labeled as a Function for it to run from a macro or via the run command. Secondly I don't know of anyway you can target a remote machine to open and run Access using Excel. The process would have to be launched from the target machine itself, you could do this by having a scheduled task, or a background process scanning for a specific file that you place somewhere, or if you have the ability to program using WINSOCKS you could create your own listener over an unused network socket.
 

Users who are viewing this thread

Back
Top Bottom