'Running MsAccess macro with PowerShell fails on Quit command (in macro)
I'm triggering a macro with the PowerShell script below:
$ApplicationName = "ODIN"
$ApplicationPath = "D:\Sales\ODIN\ODIN - copy.accdb"
$Macro = "McrAutoexec"
$MsAccess = New-Object -ComObject Access.Application
$MsAccess.OpenCurrentDatabase($ApplicationPath)
$MsAccess.visible = $true
$MsAccess.DoCmd.RunMacro("McrAutoexec")
This runs fine until the final command in the macro, to quit access (exit). I then get this error message:
The RunMacro action was canceled.
When I remove that line no error appears.
Till now it was started via a simple command line: "C:\Program Files\microsoft office\office16\msaccess.exe" "D:\Sales\ODIN\ODIN.accdb" /X "McrAutoexec"
Can someone help me out here?
PS. I know I can close the Access database with the script as well, but I need to convert a lot of batch commands to PowerShell, so I want to keep it as much as it is right now...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
