How to open document that contains AutoOpen macro with powershell?
- by grom
My current powershell script:
$document = "C:\\test.doc"
$word = new-object -comobject word.application
$word.Visible = $false
$word.DisplayAlerts = "wdAlertsNone"
$word.AutomationSecurity = "msoAutomationSecurityForceDisable"
$doc = $word.Documents.Open($document)
$word.ActivePrinter = "\\http://ptr-server:631\pdf-printer"
$background = $false
$doc.PrintOut([ref]$background)
$doc.close([ref]$false)
$word.quit()
But it results in an alert box "The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros."
How can I open the document without it running the AutoOpen macro or displaying any sort of dialog prompt?