lordicast 0 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] Share this post Link to post Share on other sites
evilertoaster 3 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? Share this post Link to post Share on other sites
saywell 3 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 Share this post Link to post Share on other sites
BugFix 43 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 Share this post Link to post Share on other sites
lordicast 0 Posted October 18, 2010 Thanks for replies, yes it is a textbox and it driving me mad! [Cheeky]Comment[/Cheeky] Share this post Link to post Share on other sites
lordicast 0 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] Share this post Link to post Share on other sites
RobertNaylor 0 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 Share this post Link to post Share on other sites