PowerShell for Windows Admins

Apr 29 2014   7:39AM GMT

Update on Office error

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:

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

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: