FINDTEXT

J

Joe

Hi,
I am using the Execute Method (Find Object) to find
either "<S****>" or "<F****>". How can i code in vba to
either one of them in vb?

regards,
Joe
 
H

Helmut Weber

Hi Joe,
I am assuming what you want to find is
an opening pointed bracket "<", followed by either "S" or "F",
followed by 4 characters, followed by a closing pointed bracket ">".
Then it would be:
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
.Execute
End With
End Sub
---
Sub Test731()
resetsearch
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "\<[FS]????\>"
.MatchWildcards = True
While .Execute
oRng.Select
MsgBox "found"
oRng.Start = oRng.End
oRng.End = ActiveDocument.Range.End
Wend
End With
End Sub
In case you are searching for an opening pointed bracket "<",
followed by either "S" or "F", followed by 4 asterisks "****",
followed by a closing pointed bracket ">", the search string
would be "\<[FS]\*\*\*\*\>". Which could be abbreviated, probably,
but would be of no practical use.
Visit: http://word.mvps.org/faqs/General/UsingWildcards.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top