Showing posts with label Powershell and word. Show all posts
Showing posts with label Powershell and word. Show all posts

Monday, November 23, 2015

PowerShell & Microsoft Word 2016 : Opening Clipboard in Word 2016 using PowerShell.

 

In the previous blog posts, we have seem that how can we set the zoom view of a document.

Ok!, this task seems to be tricky one, they ( those wizards), asked me to open Word Clipboard!!!! What!!!!!!

Yes, they asked me if I can open a word clipboard using PowerShell.

At , first , it seems to be a tough job for me , but, you do remember that PowerShell is easy? Yes?

After few hit and tries, I have found it out, it's veryyyyyy simple. Word COM object have a method  by the name of ShowClipboard ( ) .

Simple!!!!!

$word.ShowClipboard()

The complete code is :

 

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

$word.Visible = $true

$word.ShowClipboard()

Aman Dhally - Manya Kaur

Now' let's see, what will be the next challenge may be!

Aman Dhally - Manya Kaur

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”.

Wednesday, November 18, 2015

PowerShell & Microsoft Word 2016 : Opening existing Word Documents using PowerShell.

 

In the previous post, we have seem that how can we can create a new word document using the templates. We have seen how to add and create new documents, but, we hasn't seen, how to open existing documents yet!

To open existing documents, we use the Open( ) , method of the application class.

Let's create a path to my existing word document file :

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

and then then we have to use the open( ) method. and in parentheses provide the name of the file which we want to be open.

$word.Application.Documents.open($myFile) | Out-Null

That's all :)

The complete code should be look like.

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

$word.Visible = $true

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

$word.Application.Documents.open($myFile) | Out-Null

try it :)

Aman Dhally - Manya kaur

giphy

 

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”.

Sunday, November 15, 2015

PowerShell & Microsoft Word 2016 : Opening Word 2016 Desktop Application using PowerShell.

 

In my office, we have some "Word Wizards" , the "CHOSEN ONES" those write add-ins for Microsoft Office applications. Mainly Ms-Office add-ins written in either, in-built visual.net code or by using VSTO in visual studio.

Last week, I have an friendly argument with one of "Wizard"  in my office, about, PowerShell and Word. I told him, that we can do almost anything with PowerShell and He said " Can you Automate Office applications?" and I replied as "YES" (OOPS).

And that, the day, when our battle started, he keep asking me to to do this and that, and I was trying to figure out "How to do that", sometimes, if feels like "Gandalf" and "Dumbledore" are fighting with each other.

3489253-1dumbledore

But, these fighting ( not literally)  comes out as very educating and for me :) . So, I planned to write articles about it. I am sure, that you will learn something from this too.

Today, we are going to see, that how can we open Microsoft Word using PowerShell.

Our first task is to open Microsoft word, and we are going to use the COM object for it. Name of the Word's COM object is "Word.Application". and we have to use the New-Object cmdlet, to map com object to the variable.

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

 

After that, we have to set the Visible property of $word as true, otherwise we won't be able to see word.

 

$word.Visible = $true

 

After that, we jus need to type our variable $word and hit enter to open Microsoft Word.

 

Aman Dhally - Manya Kaur

You may see a lot's of Output after  running $word variable, you can omit that output by adding pipe and Out-Null variable.

$word | Out-Null

 

In , next blog post we will see, we will deal with word documents :) , Stay tunes for more, and thanks for reading the blog post.

 

Aman Dhally - Manya Kaur

 

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”.