ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Access Macro with Excel Macro (https://www.excelbanter.com/excel-programming/390079-run-access-macro-excel-macro.html)

bodhisatvaofboogie

Run Access Macro with Excel Macro
 
I am utilizing macros within some access databases that I have created
through some of the excel macros I also use. I have a formula that works
ALMOST. It is supposed to open the database, run the macro, then close the
databse. I can get it to do everything but recognize my access databse.
Perhaps I am messing up the syntax, any suggestions??? Thanks!!!

Sub RunAccessMacro()
Dim appAcc As Access.Application

Set appAcc = New Access.Application
appAcc.Visible = True

THIS IS THE LINE THAT IS BUSTED!
appAcc.OpenAccessProject "G:\MACHINE DOWN AUDIT DB\QUAD 3 MDA AUTO.mdb"

appAcc.DoCmd.RunMacro "MARSHALL"
appAcc.Quit
Set appAcc = Nothing

Everything works fine except that line that I mentioned. I can get things
to run smoothly if I already have the databse open, but if I use the code it
always bugs out on that line as if it doesn't recognize my database as
existing.



Dave Miller

Run Access Macro with Excel Macro
 
This will work for you, as long as you have a reference set for
Microsoft Access:

Regards,
David Miller


Sub RunAccessMacro()
Dim appAcc As Access.Application

Set appAcc = CreateObject("G:\MACHINE DOWN AUDIT DB\QUAD 3 MDA
AUTO.mdb")

With appAcc
.Visible = True
.DoCmd.RunMacro "MARSHALL"
.Quit
End With

Set appAcc = Nothing
End Sub



All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com