Product: PowerShell Universal
Version: 1.4.6
New-Object -ComObject Word.Application not working in 5.6.0,
Upgraded our server from 4. something to 5.6 and havin issues with creating word Docs
If i use this example code from powershell ISE logged in as the user account that runs PSU it creates the document:
$word = New-Object -ComObject Word.Application
$word.Visible = $True # Set to $true if you want to see Word open$doc = $word.Documents.Add()$selection = $word.Selection
$selection.TypeText(“This is a document created with PowerShell.”)
$filePath = “D:\PSU_Data\Add Users\Welcome Sheets Files\MyPowerShellDocument.docx”
$doc.SaveAs([ref]$filePath)
$doc.Close()
$word.Quit()
This exact Code in a new APP does nothing
New-UDApp -Content {
New-UDButton -Text "Click Me!" -onclick {
\# Create a new Word Application object
$word = New-Object -ComObject Word.Application
$word.Visible = $True # Set to $true if you want to see Word open
\# Add a new document
$doc = $word.Documents.Add()
\# Get the selection object (where the cursor is)
$selection = $word.Selection
\# Insert text
$selection.TypeText("This is a document created with PowerShell.")
\# Save the document
$filePath = "D:\\PSU_Data\\Add Users\\Welcome Sheets Files\\MyPowerShellDocument.docx"
$doc.SaveAs(\[ref\]$filePath)
Show-UDToast -Message "Test"
\# Close the document and Word application
$doc.Close()
$word.Quit()
If i open task manager i can see Word gets opened but none of the other code will run except the toast