Here is what we have come up with, but it is failing at the moment.
"Exception calling "Add" with "1" argument(s):"Word was unable to read this document. It may be corrupt."
If we run the script locally and not through Adaxes it works fine.
Thanks,
Tony
$word = New-Object -ComObject "Word.application"
$word.Visible = $false
$doc = $word.Documents.Add("C:\temp\EULA.dotx")
#Variables
$fullname = "%fullname%"
$password = "%unicodePwd%"
$emailaddress = "%mail%"
$username = "%username%"
$FindFullname = "Fullname1"
$FindUsername = "username1"
$FindEmail = "emailaddress1"
$FindPassword = "password1"
$ReplaceAll = 2
$FindContinue = 1
$MatchCase = $False
$MatchWholeWord = $True
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $FindContinue
$Format = $False
$selection = $word.Selection
$selection.Find.Execute($FindFullname,$MatchCase,
$MatchWholeWord,$MatchWildcards,$MatchSoundsLike,
$MatchAllWordForms,$Forward,$Wrap,$Format,
$fullname,$ReplaceAll)
$selection.Find.Execute($FindUsername,$MatchCase,
$MatchWholeWord,$MatchWildcards,$MatchSoundsLike,
$MatchAllWordForms,$Forward,$Wrap,$Format,
$username,$ReplaceAll)
$selection.Find.Execute($FindEmail,$MatchCase,
$MatchWholeWord,$MatchWildcards,$MatchSoundsLike,
$MatchAllWordForms,$Forward,$Wrap,$Format,
$emailaddress,$ReplaceAll)
$selection.Find.Execute($FindPassword,$MatchCase,
$MatchWholeWord,$MatchWildcards,$MatchSoundsLike,
$MatchAllWordForms,$Forward,$Wrap,$Format,
$password,$ReplaceAll)
$file = "C:\temp\$username.docx"
$word.ActiveDocument.SaveAs([ref]$file)
$quitFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveOptions],"wdDoNotSaveChanges")
$Word.Quit([ref]$quitformat)