Run Access Macro with Excel Macro

B

bodhisatvaofboogie

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.
 
D

Dave Miller

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
 
M

MH

You are using the wrong method to open an mdb file, use:

OpenCurrentDatabase

Instead.

MH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top