【发布时间】:2012-02-27 20:34:57
【问题描述】:
我当前的 PowerShell 脚本:
$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()
但它会导致一个警告框此项目中的宏被禁用。请参考宿主应用程序的在线帮助或文档来确定如何启用宏。
如何在不运行AutoOpen 宏或显示任何类型的对话框提示的情况下打开文档?
环境详情:
- Word 2003 SP3
- Windows Server 2003 R2 - 标准版 - Service Pack 2
- Powershell 1.0 版
【问题讨论】:
-
我很乐意对此进行更深入的研究,尤其是新的赏金,但需要有关您的环境的更多详细信息来解决为什么我在下面的第一个答案不起作用。什么版本的 PowerShell?什么版本的Word?什么操作系统?等等。
-
如果我有代表,我什至会付出更大的赏金。我已经用尽谷歌的答案并且完全被卡住了。
标签: powershell ms-word