mcgill Posted November 21, 2006 Share Posted November 21, 2006 Is it possible to read data in a microsoft word( .doc ) file searching for specific criteria and then copy a line in the file where the data is found...export to a text file. I have been playing around with the word.au3 and there is a replace string but no find option. Has there been an update to the word.au3 or can anyone else give me a way of doing it, thanks Link to comment Share on other sites More sharing options...
Valuater Posted November 21, 2006 Share Posted November 21, 2006 (edited) big_daddy has created a Word UDF.. its located in Example Scripts SectionI am sure it will do what you want ... and much moreits herehttp://www.autoitscript.com/forum/index.ph...461&hl=word8) Edited November 21, 2006 by Valuater Link to comment Share on other sites More sharing options...
mcgill Posted November 23, 2006 Author Share Posted November 23, 2006 I would like to search for a string in a word document and once the string is found I would like to copy data that is a tab over from the search string. I do not see a Find function in the word.au3/udf, there is a FindandReplace. If anyone has done anything like this help would be greatly appreciated, thanks Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted November 26, 2006 Moderators Share Posted November 26, 2006 This was a fun one! I learned a lot of new tricks to can be used with ranges. This may not be exactly what you need, but you should be able to modify it to fit your needs. If you have any more questions feel free to ask. #include <Word.au3> $iFound = 0 $oWordApp = _WordCreate (@ScriptDir & "\Test.doc") $oDoc = _WordDocGetCollection ($oWordApp, 0) ; Specifies a range object of the entire document $oRng = $oDoc.Range ; Loop through found items While Not @error ; Search for "This" in the range specified above ; After searching the range is changed to the found text _WordDocFindReplace ($oDoc, "This", "", 0, $oRng, 0, 0, 0, 0, 0, 1, 0) If Not @error Then ; Duplicates range leaving the original unchanged $oTempRng = $oRng.Duplicate ; Expands the new range to the start and end of the current sentence $oTempRng.SetRange ($oTempRng.Sentences (1).Start, $oTempRng.Sentences (1).End) ; Return all text within the range to the console ConsoleWrite($oTempRng.Text & @CR) $iFound += 1 EndIf WEnd If $iFound > 0 Then MsgBox(0, "Success", "Found " & $iFound & " occurrences.") Else MsgBox(0, "Error", "Not Found") EndIf _WordQuit ($oWordApp, 0) Link to comment Share on other sites More sharing options...
LxP Posted December 1, 2006 Share Posted December 1, 2006 For anyone else who comes across this thread during a search and wants to convert an entire Word document to a plain text file (which could then be searched using native AutoIt functions, etc.), Antiword is one possible approach.This is extremely handy for systems that don't actually have Microsoft Word installed. 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