Excel macro to open access and run Access macro - Run-time Error 7866

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
Hello, I am trying to run the following macro from my excel workbook that opens my Microsoft Access database and runs a macro that imports all of my data. It opens access successfully, but then I get the following error:

Run-time error '7866':
Microsoft Access can't open the database because it is missing, or opened exclusively by another user, or it is not an ADP file.

It is located in this file location, and its not opened by anyone (only I have access to it). Any ideas how to fix this, or do you have any thoughts on how I can accomplish this another way?

Code:
Sub accessMacro()
Dim accessApp
Set accessApp = CreateObject("Access.Application")
accessApp.Visible = True
accessApp.OpenCurrentDataBase ("C:\Users\1234\Desktop\Access Database")
accessApp.Run "MasterImport"
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
There is no extension in that file name. Are you sure you are opening it successfully? More likely you are just opening Access, but not any actual database.
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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