2016-03-23 5 views
1

Ich habe dieses Skript, das eine Outlook-Signatur erstellt und Active Directory nach Datum (DisplayName, Telefon und Titel) überblickt.Outlook 2016 Signatur und Active Directory

Ich habe diese Codezeile, um eine .docx-Datei nach appdata zu kopieren und in html, rtf und txt zu speichern.

#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() 

Es funktioniert für Outlook Fein 2013 Aber wenn ich es für Outlook 2016 lief, habe ich folgende Fehler

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 

Gibt es eine andere Formatierung für Outlook 2016. Gedanken erhalten?

Danke!

+0

Ausführung Was Sie für die Mitarbeiter auf osx oder MacOS @ Rob tun – OnkelK

Antwort

0

Versuchen Sie, das Skript in 32-Bit PowerShell auszuführen, wenn Sie 32-Bit-Office installiert haben.

Ich habe eine .bat Datei die unter + das Skript

%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe c:\myscript.ps1