Call Access macro in module from Excel

harrycosh

New Member
Joined
Feb 27, 2009
Messages
25
Hi All

I hope I can find some help.

I need to call a macro that is in an access database but I get the error:

Run-time error '2485':

Microsoft Office Access can't find the object 'YourMacroName.'

My code is below that I am currently using:

Public Sub RunAccessMacro()

Dim strDatabasePath As String
Dim appAccess As Access.Application
Dim MacroNameString As String

MacroNameString = "YourMacroName"
strDatabasePath = "c:\Work\Factbase.accdb"

Set appAccess = New Access.Application

With appAccess
Application.DisplayAlerts = True
.OpenCurrentDatabase strDatabasePath
.DoCmd.RunMacro MacroNameString
.Quit
End With

Set appAccess = Nothing

End Sub

I am not sure what I am doing wrong?

Thanks in advance
moz-screenshot.png
 
MyMac is an Access macro which is not the same as an Excel VBA Macro

You can call module code in access from the outside
the easiest is to create an Access macro that calls the vb function or subroutine in the module, but there are other ways
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,216,100
Messages
6,128,834
Members
449,471
Latest member
lachbee

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