question

GaryMercer-0146 avatar image
0 Votes"
GaryMercer-0146 asked GaryMercer-0146 answered

PowerShell - application.opencurrentdatabase password prompt

I'm using PowerShell to connect to a MS Access database stored on a UNC to run a macro. This is the code I'm using...

$MsAccess = New-Object -ComObject Access.Application
$MsAccess.OpenCurrentDatabase('\*****\db.accdb', $False, 'password')
$MsAccess.Visible = $true
$MsAccess.Application.DoCmd.RunMacro("Macro1")
$MsAccess.CloseCurrentDatabase()
$MsAccess.Quit()

The password I'm supplying is correct as it works when I manually open the database. When I run this code I'm still being prompted to supply the password for the database...

97902-image.png

Using the same code works for other password protected databases but just not on this one.

Any help is greatly appreciated.

windows-server-powershell
image.png (3.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

GaryMercer-0146 avatar image
0 Votes"
GaryMercer-0146 answered

Just in case anybody stumbles across this, always double check the permissions on the UNC folder where the database is stored!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.