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