Page 1 of 1

Replace text / skip formated text

Posted: Wed May 26, 2021 1:29 pm
by BubikolRamios

Code: Select all

   oReplace = oDoc.createReplaceDescriptor()

  For i= Lbound(matrix,1) To Ubound(matrix,1)
    
     oReplace.SearchString = matrix(i)(0)           'Regular expression. Match any text
     oReplace.ReplaceString =  matrix(i)(1)           
     'msgbox ( matrix(i)(0))
     oReplace.SearchRegularExpression=False  'Use regular expressions
     oReplace.SearchCaseSensitive = False
     'oReplace.searchStyles=True             'We want to search styles
     oReplace.searchAll=True                'Do the entire document
assuming matrix has pairs like [[foo][foo1]]

How about not replacing if foo is entirely red or just part of it red ?

Re: Replace text / skip formated text

Posted: Wed May 26, 2021 2:09 pm
by JeJe
Do a search (not a search replace). Go through all the results and only replace the ones you want.

Edit:
You can do another search with the selection returned by a search - but if I remember rightly you have to use the dispatch helper to do a search within a selection.