header image

Update on Office error

Posted by: | April 29, 2014 | 1 Comment |

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

under: Office 2013, PowerShell v4, Windows 8.1

1 Comment

  1. By: Jason on April 29, 2014 at 11:36 am      

    Worked: PSv4, Win7 Enterprise, Office 2010