Hi,
I'd be very grateful for help with the following.
I have a text file open in Word. I need an example of how to use a
regular expression to search for ranges of text that begin with
'\begin{figure}' and end with '\end{figure}' inclusive.
\begin{figure}
Any text can go here etc etc etc
\end{figure}
Once this is found, I would like to convert it to a Word Range object
and then continue the regular expression search from the next point in
the document.
Thanks in advance,
Enda
Helmut Weber - 27 Jun 2005 16:07 GMT
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"
enda_ridge@excite.com - 28 Jun 2005 13:43 GMT
Hi Helmut,
Thanks for your help.
Enda