Hello Forum -
I am trying to write a module in Excel so that when it is run, it opens up an Access Database saved on my hard drive and runs a macro. The following code works well and runs the macro, but the problem is that it prompts the user for the database password. This password will not be distributed to the group so I am trying to find a way to programatically include the password. Does anyone know where I would insert the password in the code?
I am trying to write a module in Excel so that when it is run, it opens up an Access Database saved on my hard drive and runs a macro. The following code works well and runs the macro, but the problem is that it prompts the user for the database password. This password will not be distributed to the group so I am trying to find a way to programatically include the password. Does anyone know where I would insert the password in the code?
Code:
dim strDbName as string
dim acc as Access.Application
strDbName = "C:\Documents\database1.accdb"
Set acc = New Access.Application
With acc
Application.DisplayAlerts = False
.OpenCurrentDatabase strDbName
.Docmd.RunMacro "AutoExec"
.Quit
End With
Set acc = Nothing