-
Say I have an Accesss file which has a Macro named Macro1. Or, say I have a Procedure in an Access Module
named Procedure1. Can I call those from within VB6 to execute? How would this be done? Also, would Access
have to be installed on the end user's machine for this to work?
Thanks,
Dan
-
It's possible by using this code (you must add a reference to the 'Microsoft Access Object library')
Code:
Dim appAccess As Access.Application
' Open Access
Set appAccess = CreateObject("Access.Application")
' Make Access visible
appAccess.Visible = True
' Open your database
appAccess.OpenCurrentDatabase "MyPathAndDBName"
appAccess.Run "MyFunctionName" ' Only a function, not a sub
appAccess.DoCmd.RunMacro "MyMacroName"
' Close your Database
appAccess.CloseCurrentDatabase
' Close Access
appAccess.Quit
Set appAccess = Nothing
I think that Only the MSACC8.OLB (if you use Access97) must be on the client PC