cmarti
(Hey THIS is FUN)
2003-09-18 07:45 PM
Easy one for somebody...How do I close a word file before closing word?

Right now I'm opening word, inserting a file, saving, and exiting word. How do I close the file before exiting out of word?

Here's what I have already. Variables are populated earlier in the script...
code:
$WordDoc = CreateObject('Word.Application')
$AddTemplate = $WordDoc.Documents.Add(E:\Invoices\Templates\$Template.doc)
$WordDoc.Selection.InsertFile($DirectoryPath\$FileToFormat)
$FormattedDoc = SubStr($FileToFormat,1,Len($FileToFormat) -4)
$SaveWordDoc = $WordDoc.ActiveDocument.SaveAs("$SavePath\$FormattedDoc.doc",0)
$WordDoc.Quit(0)



Kdyer
(KiX Supporter)
2003-09-18 07:47 PM
Re: Easy one for somebody...How do I close a word file before closing word?

I am going to take a guess here..
code:
$WordDoc.ActiveDocument.Close

Kent


cmarti
(Hey THIS is FUN)
2003-09-18 09:17 PM
Re: Easy one for somebody...How do I close a word file before closing word?

You're good...that worked perfectly!!! Thank you!!! [Big Grin]

L8tr...