D
DDBeards
I want to run an Access Macro via Code from Excel, however I am getting an
error in Access I believe because the MDB is set up to open a menu form
automatically on open. I can get around it when opening Access by holding
the shift key down. What I would like to know is there away via code to do
the same thing so I can just run the macro?
Here is my code:
Dim appAcc As Access.Application
'Opens Access or gets reference to app already running
Set appAcc = New Access.Application
'Optional to show or hide Access
appAcc.Visible = True
appAcc.OpenAccessProject ("O:\Resources\O36 Databases\CPAP\O36_CPAP.mdb")
'For running a regular Access macro
appAcc.DoCmd.RunMacro "CPAP_Qtr_Export"
'For running a VBA macro
'appAcc.RunMacro "MyAccessMacro"
'Close Access
appAcc.Quit
'This will close Access, even w/o the 'Quit' command
Set appAcc = Nothing
I am sure has to do with the " appAcc.OpenAccessProject
("O:\Resources\O36 Databases\CPAP\O36_CPAP.mdb")" line.
Thanks
error in Access I believe because the MDB is set up to open a menu form
automatically on open. I can get around it when opening Access by holding
the shift key down. What I would like to know is there away via code to do
the same thing so I can just run the macro?
Here is my code:
Dim appAcc As Access.Application
'Opens Access or gets reference to app already running
Set appAcc = New Access.Application
'Optional to show or hide Access
appAcc.Visible = True
appAcc.OpenAccessProject ("O:\Resources\O36 Databases\CPAP\O36_CPAP.mdb")
'For running a regular Access macro
appAcc.DoCmd.RunMacro "CPAP_Qtr_Export"
'For running a VBA macro
'appAcc.RunMacro "MyAccessMacro"
'Close Access
appAcc.Quit
'This will close Access, even w/o the 'Quit' command
Set appAcc = Nothing
I am sure has to do with the " appAcc.OpenAccessProject
("O:\Resources\O36 Databases\CPAP\O36_CPAP.mdb")" line.
Thanks