Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Error using _WordDocReplace.......

$
0
0
I am having some trouble understanding where my formatting is wrong in this code, specifically with the _WordDocFindReplace parameters:


;Open the letter template and fill out the form
Local $myTemplate = @ScriptDir & "\templates\ Letter.doc"

Local $oWordApp  = _WordCreate("", 0, 0)
Local $oDoc = _WordDocOpen($oWordApp, $myTemplate)

Local $oFind = _WordDocFindReplace($oDoc, "[TN]", $EspStatTN)
Local $oFind = _WordDocFindReplace($oDoc, "[USERNAME]", $EspStatUsername)
Local $oFind = _WordDocFindReplace($oDoc, "[PASSWORD]", $EspStatPassword)
Local $oFind = _WordDocFindReplace($oDoc, "[EMAILADDRESS]", $EspStatUsername)
Local $oFind = _WordDocFindReplace($oDoc, "[IPBLOCK]", $EspStatIPBlock)
Local $oFind = _WordDocFindReplace($oDoc, "[NETMASK]", $EspStatNetmask)
Local $oFind = _WordDocFindReplace($oDoc, "[NETMASK]", $EspStatNetmask)


_WordDocSaveAs($oDoc, @ScriptDir & "\Test.doc")
_WordQuit($oWordApp)


At runtime the error is actually occurring within the Word.au3 UDF.  I'm not sure why it's saying there is an error in the expression, because I followed the example code here:

http://www.autoitscript.com/autoit3/docs/libfunctions/_WordDocFindReplace.htm

The error returned is:

 

C:\Program Files\AutoIt3\Include\Word.au3 (749) : ==> Error in expression.:
$return = .Execute($s_FindText, $f_MatchCase, $f_MatchWholeWord, $f_MatchWildcards, $f_MatchSoundsLike, $f_MatchAllWordForms, $f_Forward, $i_Wrap, $f_Format, $s_ReplaceWith, $i_Replace)
$return = .Execute($s_FindText, $f_MatchCase, $f_MatchWholeWord, $f_MatchWildcards, $f_MatchSoundsLike, $f_MatchAllWordForms, $f_Forward, $i_Wrap, $f_Format, $s_ReplaceWith, $i_Replace)^ ERROR

Any assistance narrowing down where my error is here is greatly appreciated.   Basically, I'm opening an existing document, executing a Find/Replace function to fill out a form, and then saving the resulting file back out.

-hogfan

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>