ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open PW-Protected MS Access db using Excel VBA (https://www.excelbanter.com/excel-programming/322247-open-pw-protected-ms-access-db-using-excel-vba.html)

Mike

Open PW-Protected MS Access db using Excel VBA
 
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


Chip Pearson

Open PW-Protected MS Access db using Excel VBA
 
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




"Mike" wrote in message
...
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





All times are GMT +1. The time now is 01:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com