Word New Document

Lets add another function to our module for working with Word.  Its time to create a new word document

001
002
003
004
005
function New-WordDocument {
    $word = New-Object -ComObject Word.Application
    $word.Visible = $true
    $Word.Documents.Add() | Out-Null
}

 

Create the object for word as before.  Set the visible property to true (we can’t use it if we can’t see it)  We then add a document.  The Out-Null I found was necessary on my Windows 7 & Office 2010 combination because a lot of stuff was generated that I didn’t want to see.  Try it without on other combinations.  I don’t remember it being so bad with Word 2007

Published Fri, Aug 28 2009 20:13 by RichardSiddaway
Filed under:

Leave a Comment

(required) 
(required) 
(optional)
(required) 
If you can't read this number refresh your screen
Enter the numbers above: