I am attempting to run an Access 2003 macro from within Excel (2003) VBA.
I found this snippet of code from the mrexcel.com site...
http://www.mrexcel.com/archive/VBA/8278.html
I am simply testing this code in my own Excel file like this...
When I run this macro from Excel, I get the following error...
Now, I have verified the Access database filename, and I am sure that the file is closed when I try to run this macro. The only thing that I can think of is the fact that the standard security warning appears when I try to open the Access file manually....Could this be part of my problem?
Thanks!
I found this snippet of code from the mrexcel.com site...
http://www.mrexcel.com/archive/VBA/8278.html
Code:
Private Sub CommandButton1_Click()
Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "[Insert database path]"
appAccess.DoCmd.RunMacro "[Insert macro name]"
Set appAccess = Nothing
End Sub
I am simply testing this code in my own Excel file like this...
Code:
Sub Run_Access_Macro()
Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "C:\test.mbd"
appAccess.DoCmd.RunMacro "Macro1"
Set appAccess = Nothing
End Sub
When I run this macro from Excel, I get the following error...
Code:
Run-time error '7866':
Microsoft Office Access can't open the database because it is missing,
or opened exclusively by another user.
Now, I have verified the Access database filename, and I am sure that the file is closed when I try to run this macro. The only thing that I can think of is the fact that the standard security warning appears when I try to open the Access file manually....Could this be part of my problem?
Thanks!