finding non-leading numbers

J

John Smith

I use findtext:="[0-9]{1,}" to find all the numbers in an article and
change their format to subscript. Then, I use "<[0-9]{1,}" to cancel the
subscript of those numbers that are in the beginning of a word.

Is it possible to consolidate the above, i.e. finding only the
non-leading numbers in one pass? Thanks.
 
G

Graham Mayor

This appears to be an extension of your earlier problem. You could use
findText:="[! ^13^11][0-9]{1,}"
then drop the leading character as follows. This will find any number that
doesn't follow a space a line break or a paragraph and is not the first
character in the document.

Dim rText As Range
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(findText:="[! ^11^13][0-9]{1,}", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set rText = Selection.Range
rText.MoveStart Unit:=wdCharacter, Count:=1
rText.Font.Subscript = True
Loop
End With
End With

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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