dragaron Posted August 1, 2007 Share Posted August 1, 2007 This is just for my own instructional purposes at this point. Goal: To open an existing word ".doc" on my desktop named "Test.doc", and replace "EEE" with "FFF", add a Return, then save the document. This script runs without errors, but "EEE" is still in the document when I open it after the script is complete - Nothing changed. Contents of "Test.doc", without the quotes obviously: "This is just a test. AAA, BBB, CCC, EEE." Contents of AutoIt Script: $oWordApp = _WordCreate ("") $oDoc = _WordDocOpen ($oWordApp, "C:\Documents and Settings\Owner\Desktop\Test.doc") $oFind = _WordDocFindReplace($oDoc, "EEE", "FFF" & @CRLF) _WordDocSave ($oDoc) _WordQuit ($oWordApp) Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 1, 2007 Share Posted August 1, 2007 This is just for my own instructional purposes at this point.Goal: To open an existing word ".doc" on my desktop named "Test.doc", and replace "EEE" with "FFF", add a Return, then save the document. This script runs without errors, but "EEE" is still in the document when I open it after the script is complete - Nothing changed.Contents of "Test.doc", without the quotes obviously:"This is just a test. AAA, BBB, CCC, EEE."Contents of AutoIt Script:$oWordApp = _WordCreate ("")$oDoc = _WordDocOpen ($oWordApp, "C:\Documents and Settings\Owner\Desktop\Test.doc")$oFind = _WordDocFindReplace($oDoc, "EEE", "FFF" & @CRLF)_WordDocSave ($oDoc)_WordQuit ($oWordApp)There's no #include. What UDF are you using for the _Word* funcitons? Are there any errors on the SciTE console when you run it? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GMK Posted August 1, 2007 Share Posted August 1, 2007 This should work better: #include <Word.au3> $oWordApp = _WordCreate () $oDoc = _WordDocOpen ($oWordApp, @DesktopDir & "\Test.doc") $oFind = _WordDocFindReplace($oDoc, "EEE", "FFF" & @CR) _WordDocSave ($oDoc) _WordQuit ($oWordApp) Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted August 2, 2007 Moderators Share Posted August 2, 2007 This is just an optimized version of GMK's code. #include <Word.au3> $oWordApp = _WordCreate(@DesktopDir & "\Test.doc") $oDoc = _WordDocGetCollection($oWordApp, 0) _WordDocFindReplace($oDoc, "EEE", "FFF" & @CR) _WordDocSave($oDoc) _WordQuit($oWordApp) Link to comment Share on other sites More sharing options...
dragaron Posted August 2, 2007 Author Share Posted August 2, 2007 Thank you everyone. I forgot "#include <Word.au3>". I appreciate the help and am really loving this program. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now