Run Access Macros in Excel

bobdole22

New Member
Joined
Aug 28, 2013
Messages
4
I am trying to run this code, I got from another thread on this forum that is closed. I'm sure it's been used a ton of times. 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:

VB:

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 </pre>

I am getting the error
User-defined Type not defined

on line:

Set appAccess = New Access.Application
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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.
 
Upvote 0

Forum statistics

Threads
1,218,062
Messages
6,140,237
Members
450,268
Latest member
Spnumbersnewb

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top