Thursday, November 19, 2015

PowerShell & Microsoft Word 2016 : Setting Zoom view levels of Word 2016 document.


Now, from here the things has started complicated, One of the "Word Wizard" in my office asked me to open a document in a particular zoom type.

I hope  you have noticed a zoom bar in word before, by moving you are zoom-in-and-zoom-out a document.  This was the tricky question, but after a research, I have manage to do it.

It' is only one liner :)

In the below line of code, I am setting a zoom view to 200%. Remember the property is in percentage.

$word.Application.ActiveWindow.View.Zoom.Percentage = 200;

That's all, rest of the code is same.

The complete code is :

$word = New-Object -ComObject "Word.Application"

$word.Visible = $true

$myFile = "C:\Users\aman.dhally\Documents\PolyCom-ThreeParty Conefrence.docx"

$$myFile) | Out-Null

$word.Application.ActiveWindow.View.Zoom.Percentage = 200;

It's cool no?

NOTE :  The Zoom only works, if you have an document already open, otherwise, you will get an exception error.

Aman Dhally - Manya Kaur

giphy (1)

With Regards.
Aman Dhally
If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.

No comments:

Post a Comment