Update on Office error

Back in this post http://richardspowershellblog.wordpress.com/2012/10/15/powershell-3-and-word/

I showed that this code

$word = New-Object -ComObject "Word.application"           
$word.visible = $true           
$doc = $word.Documents.Add()           
$doc.Activate()           
           
$word.Selection.Font.Name = "Cambria"           
$word.Selection.Font.Size = "20"           
$word.Selection.TypeText("PowerShell")           
$word.Selection.TypeParagraph()           
           
$word.Selection.Font.Name = "Calibri"           
$word.Selection.Font.Size = "12"           
$word.Selection.TypeText("The best scripting language in the world!")           
$word.Selection.TypeParagraph()           
           
$file = "c:\test1.doc"           
$doc.SaveAs([REF]$file)           
           
$Word.Quit()

Wouldn’t work because of an error in the way [REF] was treated. I had a comment left on the post saying it worked on PowerShell v4.

I’ve tested on PowerShell v4 on Windows 8.1 with Office 2013. It works. I can’t vouch for other combinations but it looks the problem has been resolved.

If you have the opportunity please try it and let me know if it doesn’t work for your particular combination of PowerShell v4, Windows and Office

One Response to Update on Office error

Leave a Reply