input access vb password from excel

brayshaw36

New member
Local time
Today, 20:32
Joined
Feb 13, 2016
Messages
3
How do I code Access database VB password input using VB code resident in Excel 2010? The following code works as expected and opens the access vbe window but Sendkeys is failing to open the password input box.

Sub Test()
Dim app As Object
Dim wnd As Object
Set app = CreateObject("Access.Application")
app.OpenCurrentDatabase "C:\Test Database.accdb"
app.Visible = True
For Each wnd In app.VBE.Windows
If wnd.Caption Like "Project*" Then
wnd.SetFocus
Exit For
End If
Next
SendKeys ("%Te"), True 'this line does not work
SendKeys (Pword), True
SendKeys "~", True
app.Quit acQuitSaveNone
Set app = Nothing
End Sub

Please advise if there is a better way than using Sendkeys

Obviously the final code will be secure and use an input box to interact with the user. All help appreciated.
 
app.OpenCurrentDatabase "C:\Test Database.accdb", False, Pword
 
Thanks but it is the VB Project password I want to enter - not the database open password
 

Users who are viewing this thread

Back
Top Bottom