Deye Posted May 17, 2017 Share Posted May 17, 2017 Hi, I need a good idea or a small example on how to target the find replace for a single cell for instance if there is a "zero" that needs to be found and replaced then its a problem when other cells contain zeros Didn't really yet get to find out more of the possibility's available .. looking TIA Link to comment Share on other sites More sharing options...
Subz Posted May 17, 2017 Share Posted May 17, 2017 See https://msdn.microsoft.com/en-us/library/office/ff821612.aspx Deye 1 Link to comment Share on other sites More sharing options...
Subz Posted May 17, 2017 Share Posted May 17, 2017 (edited) And here is a basic example: nb: The StringReplace Chr(7) removes the cell end ascii character Bel #include <Word.au3> Local $sWord = @ScriptDir & "\Word.docx" Local $oWord = _Word_Create() Local $oDoc = _Word_DocOpen($oWord, $sWord) If StringReplace($oDoc.Tables(1).Cell(2,2).Range.Text, Chr(7), "") = 0 Then $oDoc.Tables(1).Cell(2,2).Range.Text = 1 Edited May 17, 2017 by Subz Deye 1 Link to comment Share on other sites More sharing options...
Deye Posted May 17, 2017 Author Share Posted May 17, 2017 Thanks I'm reading the table from array and replacing like so : Func _replace($table, $row, $col, $find = "", $replace = '') $oDoc.Tables($table).Cell($row, $col + 1).Range.Text = $replace EndFunc ;==>_replace but now, how do i keep the alignment formatting of the cell after the replace takes place .. Link to comment Share on other sites More sharing options...
Subz Posted May 17, 2017 Share Posted May 17, 2017 Example:https://msdn.microsoft.com/en-us/library/office/ff835817.aspx #include <Word.au3> Local $sWord = @ScriptDir & "\Word.docx" Local $oWord = _Word_Create() Local $oDoc = _Word_DocOpen($oWord, $sWord) Local $oTables = $oDoc.Tables If StringReplace($oDoc.Tables(1).Cell(2,2).Range.Text, Chr(7), "") = 0 Then $oDoc.Tables(1).Cell(2,2).Range.Text = 1 $oDoc.Tables(1).Cell(2,2).Range.ParagraphFormat.Alignment = 1 EndIf Deye 1 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