Link to home
Start Free TrialLog in
Avatar of markpalinux
markpalinuxFlag for United States of America

asked on

How to Change MS Word Template - Headers with Powershell

I have a problem that I am trying to use Powershell to resolve.
It has to do with MS Word Office templates used as headers. File servers were changes and the old UNC path no longer exists.

Microsoft gave examples for VBA and VBscript how to make changes, however I cannot find these properties with Powershell,
I tried to look at the Office Object Model and use powershell's Get-Member but could not figure things out.

I am aware that DNS and an Alias can change things but for security we have strict name checking in place.

Documents that have attached templates take a long time to open in Word 2002 and in Word 2003
http://support.microsoft.com/kb/830561

Here are the lines I am referring to.
  Set objDoc = Documents.Open(strFilePath & strFileName)    
         Set objTemplate = objDoc.AttachedTemplate    
         Set dlgTemplate = Dialogs(wdDialogToolsTemplates)    
         strPath = dlgTemplate.Template    



So far I have:
$Document = "C:\Temp\Donation Form.doc"
$Word = New-Object -comobject Word.Application
$OpenDoc = $Word.Documents.Open($Document)
$objTemplate = $OpenDoc.AttachedTemplate
ASKER CERTIFIED SOLUTION
Avatar of Joanne M. Orzech
Joanne M. Orzech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of markpalinux

ASKER

Excellent.  Thank you.