Showing posts with label Word 2016. Show all posts
Showing posts with label Word 2016. Show all posts

Tuesday, November 24, 2015

PowerShell & Microsoft Word 2016 : Enabling / Disabling display of recent files in Word 2016 using PowerShell.

 

In the previous blog post, we have seem that how can we show Word Clipboard using PowerShell.

Now, the things are getting heated . Now my next task is to enable and disable the display of recent files in the Word 2016.

Crazy! No!

But, I manage to do it.

By default, Word 2016, show you the list of Recent files. I am task to make it off using PowerShell.

before disabled

And I manage to do this, by using.....

$word.DisplayRecentFiles = $false ; 

Simple and Cool no!

In the below screenshot you can see that, there is no recently opened files.

recent-disabled

The complete code is .

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

$word.Visible = $true

$word.DisplayRecentFiles = $false ; 

 

:)  hell Yah!

 

Note : The above only works if you open Word document using code, if you open word separately, you will see the recent files.

 

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

Tuesday, November 17, 2015

PowerShell & Microsoft Word 2016 : Creating new Word 2016 file using Word Templates.

 

In our previous blog post, we have see, that how can we create a new word file using PowerShell. Today we are going to see, that , how can we create a new word file using Word templates.

Word templates are pre-formatted word documents, which you can use as an boilerplates. The default extension of the Word Templates are .dotx.

The default location of templates is : %appdata%\Microsoft\Templates\

I have downloaded a word templates from internet and we are going to create a new document by using this template. 

$myWordTemplate = 'C:\Users\aman.dhally\AppData\Roaming\Microsoft\Templates\Flower personal business cards.dotx'

 

In the above line, I am creating a variable which stores the file location of my template. The rest of the code is as same as the pervious one , except , in the add() method, we have to provide the name of the above file , simple ;o) .

 

The complete code is :

 

#B3

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

$word.Visible = $true

$myWordTemplate = 'C:\Users\aman.dhally\AppData\Roaming\Microsoft\Templates\Flower personal business cards.dotx'

$word.Application.Documents.Add($myWordTemplate) | Out-Null

 

and here is the output.

 

Aman Dhally - Manya kaur

 

 

tumblr_lh6weimfMc1qc47qq

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