lordicast Posted October 18, 2010 Share Posted October 18, 2010 This is strange the _WordDocFindReplace works fine when replacing in a text style document but will not replace text in a table like word document. Any thoughts? [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
evilertoaster Posted October 18, 2010 Share Posted October 18, 2010 What is a "table like word document"? Is that just any document with a table in it? Any chance you can provide a repro script/word doc? Link to comment Share on other sites More sharing options...
saywell Posted October 18, 2010 Share Posted October 18, 2010 What is a "table like word document"? Is that just any document with a table in it? Any chance you can provide a repro script/word doc?I had a thread a few weeks ago about this. It won't work in a text box, but it does in a table.Regards,William Link to comment Share on other sites More sharing options...
BugFix Posted October 18, 2010 Share Posted October 18, 2010 (edited) So you can read out all cells of table: #include <Word.au3> Local $oWordApp = _WordCreate("Your.doc") Local $rows, $columns $rows = $oWordApp.Activedocument.Tables(1).Rows.Count ; if not first table, use other number for table $columns = $oWordApp.Activedocument.Tables(1).Columns.Count $i = 1 ; row $j = 1 ; col For $i = 1 To $rows For $j = 1 To $columns $oWordApp.Activedocument.Tables(1).Cell($i,$j).Select ConsoleWrite($oWordApp.Selection.Text & @CRLF) ; If $oWordApp.Selection.Text = $SearchValue Then $oWordApp.Selection.Text = $Replacement Next WEnd Edited October 18, 2010 by BugFix Best Regards BugFix  Link to comment Share on other sites More sharing options...
lordicast Posted October 18, 2010 Author Share Posted October 18, 2010 Thanks for replies, yes it is a textbox and it driving me mad! [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
lordicast Posted October 18, 2010 Author Share Posted October 18, 2010 (edited) Over a hundred files need 1 word changed! heres what i got #include <Word.au3> HotKeySet('{esc}', 'esc') Func esc() Exit 0 EndFunc ;==>esc While 1 _Move() WEnd Func _Move() Dim $MyExt[1] = ["doc"] For $i In $MyExt $search = FileFindFirstFile("*." & $i) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop TrayTip("Found File:", "Replace file " & $file, 10) $true = @ScriptDir & '\' & $file $oWordApp = _WordCreate($true, 0, 0) $oDoc = _WordDocGetCollection($oWordApp, 0) $oFind = _WordDocFindReplace($oDoc, "Orange", "Banana", 2, 0) _WordQuit($oWordApp, -1) WEnd FileClose($search) Next MsgBox(0, '', 'Done') EndFunc ;==>_Move Error: --> Word.au3 Warning from function _WordDocFindReplace, $_WordStatus_NoMatch Edited October 18, 2010 by lordicast [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
RobertNaylor Posted July 22, 2011 Share Posted July 22, 2011 (edited) I've managed to figure it out after looking at various VBA macro examples on the web For $j = 1 To $oDoc.Shapes.Count ;For all textboxes $oDoc.Shapes($j).Select ;Select Text box $oDoc.Application.Selection.WholeStory ;Select content $oFind = _WordDocFindReplace($oDoc, "yyyy", "xxxxxx",2,-1) ;Find in selected area Next HTH Edited July 22, 2011 by RobertNaylor 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