Open Access 2007 from Excel 2007 vba

Is there Excel 2007 vba code that will open an Access 2007 database and then trigger a saved import to the Access DB (from a different Excel SS)?
JSSeniorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ScriptAddictCommented:
THis code block should allow you to open an access database:
Public Sub ProcedureInAccess()

‘this VBA code is run in Excel
Dim acApp As Object
Dim db As Object
Set acApp = CreateObject("Access.Application")
acApp.OpenCurrentDatabase ("C:\MyDatabaseName.mdb")
Set db = acApp
acApp.Run "NameOfProcedureInAccess"
acApp.Quit
Set acApp = Nothing

End Sub 

Open in new window


Then just have a proceedure in access (you likely already have one)  that you call using the above code.  GL!
0
ScriptAddictCommented:
If you have any problems

Set db = acApp
Not: Set db = CurrentDb
0
JSSeniorAuthor Commented:
Hi sorry for the delayed reply.  Im getting a run time error 7866....MS cant open because its missing or opened exclusively or it is not an ADP file.

It's Access 2007 any idea's?
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

ScriptAddictCommented:
I tested this code today.  The comment marker was wrong, but I wanted to test it on a macro so I used a slightly different command then used for calling a proceedure in access.  Hopefully this will help you get where you need to go!

Merry Christmas!

-SA

Public Sub ProcedureInAccess()
'this VBA code is run in Excel
Dim acApp As Object
Dim db As Object
Set acApp = CreateObject("Access.Application")
acApp.OpenCurrentDatabase ("F:\path\databasename.mdb")
Set db = acApp
acApp.docmd.runmacro "NameOfYourMacroAsItAppearsInAccess"
acApp.Quit
Set acApp = Nothing

End Sub

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ScriptAddictCommented:
I'm not sure about that error code, it sounded like you didn't have the path and file name correct.  Did you include the file extention?  the .mdb or .accdb or w/e?

-SA
0
JSSeniorAuthor Commented:
Access 2007 basic file extention ACCDB
0
RayneCommented:
awesome guys, this also worked for me. Thank you and cheers
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.