![]() Remove-Variable MSWord WdSaveFormat Enumeration Name ![]() $myText.TypeText("My username is $($Env:USERNAME) and the date is $(Get-Date)") $myText.TypeText("This is on a new line!") # Add some text with new paragraphs in between. # Create a reference to the current document so we can begin adding text $MSWord = New-Object -ComObject Word.Application # Create a new instance/object of MS Word This example open a new document, types in some formatted text and saves the file, you can modify this to do more complex tasks. How-to: How to automate Microsoft Word in PowerShell using a COM object.įor the script below to work, the computer will need to have a copy of Microsoft Word already installed. ![]()
0 Comments
Leave a Reply. |