PDA

View Full Version : Run Access Macros in Excel



bobdole22
08-28-2013, 12:56 PM
I am trying to run this code, I got from another thread that is closed. It is supposed to link to an Access file and run it's macro.I have 2007, so my db files are ".accdb" if that changes anything. Here is the code:




Dim strDatabasePath As String
Dim appAccess As Access.Application

strDatabasePath = "C:\Users\zachk\Desktop\Strats 2011.01.accdb"
Set appAccess = New Access.Application
With appAccess
Application.DisplayAlerts = False
.OpenCurrentDatabase strDatabasePath
.DoCmd.RunMacro "qry_MakeTrustTable_Adhoc"
.Quit
End With
Set appAccess = Nothing



I am getting the error
User-defined Type not defined

on line:

Set appAccess = New Access.Application

bobdole22
08-28-2013, 02:18 PM
Actually, it only does that the second time I run it. The first time it simply reports a Blank MessageBox " ". Doesn't have any info whatsoever. Is it possible I'm getting a warning because we usually runs it with warnings off in Access? Is that possible in Excel.

Also, even stranger is that I have a MsgBox "Finished" at the end of the sub that doesn't get run. This makes me think that the code doesn't go all the way though.