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:631pdf-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?
Environment Details:
- Word 2003 SP3
- Windows Server 2003 R2 - Standard Edition - Service Pack 2
- Powershell Version 1.0
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…