Code:
Function Test()
Dim $strFilePath
Dim $strPath
Dim $intCounter
Dim $strFileName
Dim $OldServer
Dim $objDoc
Dim $objTemplate
Dim $dlgTemplate
Dim $nServer
$Form=CreateObject("Kixtart.Form")
$OldServer = $Form.InputBox("What is the server name?")
$nServer = Len($OldServer)
$strFilePath = $Form.InputBox("What is the folder location that you want to use?")
If Right($strFilePath, 1) <> "\"
$strFilePath = $strFilePath + "\"
EndIf
$strFileName = Dir($strFilePath + "*.doc")
Do While $strFileName <> ""
$Word = CreateObject("Word.Application")
$objDoc = $Word.Documents.Open($strFilePath + $strFileName)
$objTemplate = $Word.objDoc.AttachedTemplate
$dlgTemplate = $Word.Dialogs(wdDialogToolsTemplates)
$strPath = $Word.dlgTemplate.Template
If Lcase(Left($strPath, $nServer)) = Lcase($OldServer)
$Word.objDoc.AttachedTemplate = $Word.NormalTemplate
EndIf
$strFileName = Dir("")
$Save = $Word.objDoc.Save
$Close = $Word.objDoc.Close
Loop
$objDoc = ""
$objTemplate = ""
$dlgTemplate = ""
EndFunction
Test ()
Its been a frustrating lession in COM objects that's for sure !!