Answer the question
In order to leave comments, you need to log in
How to specify encodings when saving Word file in Powershell?
Hello,
I am creating a document using a PowerShell script through the Word.Application COM object and I can’t figure out how to specify the encoding in the .SaveAs() method. I write like this:
...
$SaveFormatTXT = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatText”)
$Encoding = [Enum]::Parse([Microsoft.Office.Core.MsoEncoding], "msoEncodingUTF8")
...
$MSWord = New-Object -ComObject Word.Application
$MSWord.Documents.add()
$Selection = $MSWord.Selection
$Selection.TypeText("бла бла бла")
$MSWord.ActiveDocument.SaveAs([ref]$($LocalSignatureFile + ".txt"),[ref]$SaveFormatTXT,[ref]$Encoding)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question