Open PW-Protected MS Access db using Excel VBA

G

Guest

I have code set up to open an Access database from within Excel using a VB
module. It works, but now I want to add a password to the Access database
and I can not figure out how to do it. Below is the open routine. What do I
need to add to it so it opens it with a password.

Sub OpenMsAccess()
Dim AccessApp As Object

Set AccessApp = CreateObject("Access.Application")
AccessApp.Visible = True
AccessApp.OpenCurrentDatabase "C:\TestDir\TestDb.mdb"
'process data
AccessApp.Quit
Set AccessApp = Nothing

End Sub
 
C

Chip Pearson

Mike,

Try

AccessApp.OpenCurrentDatabase filepath:="C:\TestDir\TestDb.mdb",
_
bstrPassword:="your password"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top