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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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