展望2016年签名和活动目录
问题描述:
我有这个脚本创建一个Outlook签名并查找日期(DisplayName,Telephone和Title)的Active Directory。展望2016年签名和活动目录
我有这行代码将.docx文件复制到appdata并将其保存在html,rtf和txt中。
#Save new message signature
Write-Output "Saving signatures"
#Save HTML
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML");
$path = $LocalSignaturePath+'\'+$SignatureName+".htm"
$MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)
#Save RTF
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatRTF");
$path = $LocalSignaturePath+'\'+$SignatureName+".rtf"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
#Save TXT
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText");
$path = $LocalSignaturePath+'\'+$SignatureName+".txt"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat)
$MSWord.ActiveDocument.Close()
$MSWord.Quit()
它正常工作的Outlook 2013年但是,当我跑了用于Outlook 2016年,我收到以下错误
Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat].
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:142 char:1
+ $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveForm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
[ref] cannot be applied to a variable that does not exist.
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:144 char:1
+ $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (saveFormat:VariablePath) [], RuntimeException
+ FullyQualifiedErrorId : NonExistingVariableReference
Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat].
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:147 char:1
+ $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveForm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
[ref] cannot be applied to a variable that does not exist.
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:149 char:1
+ $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (saveFormat:VariablePath) [], RuntimeException
+ FullyQualifiedErrorId : NonExistingVariableReference
Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat].
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:152 char:1
+ $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveForm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
[ref] cannot be applied to a variable that does not exist.
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:154 char:1
+ $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (SaveFormat:VariablePath) [], RuntimeException
+ FullyQualifiedErrorId : NonExistingVariableReference
是否有用于Outlook 2016思考不同的格式化?
谢谢!
答
如果您安装了32位Office,请尝试在32位中运行脚本PowerShell
。
我做了一个.bat
文件执行下面+脚本
%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe c:\myscript.ps1
你是做什么的OSX或者MacOS @rob员工做 – OnkelK