Re: VBA and regular expression to search for ranges of text



Hi Enda,

lke this:


Sub Test7884()
Dim rTmp As Range
Set rTmp = ActiveDocument.Range
ResetSearch
With rTmp.Find
.Text = "\\begin\{figure\}*\\end\{figure\}"
.MatchWildcards = True
While .Execute
rTmp.Select ' for testing
Wend
ResetSearch
End With
End Sub
' ----
Public Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
' plus some more if needed
.Execute
End With
End Sub

You don't have to convert what you found to a range.
It is a range already. The question is, what do want to do with it.


Greetings from Bavaria, Germany

Helmut Weber, MVP, WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"




.



Relevant Pages