Macro to Bold Caps - Further Refined

R

Rita King

Hi
Doug Robbins provided me with the following code to apply a style (Strong)
to all capitalised text. It works a treat. (Thanks to Doug).

Sub BoldText()

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2,}", MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Selection.Range.Style = "Strong"
Loop
End With
End Sub

I now realise that some of the text that is to have the style applied has
words like
I DIRECT
I GIVE DEVISE AND BEQUEATH
the above macro works wonderfully but it does not apply the style to the
word "I".

Is it possible to refine this code further to include the word " I " when
followed by a word in capitals.

Sorry if I should have added this post to the end of my previous one but I
don't know whether posts that are weeks old ever get re-read.

Many thanks
 
D

Doug Robbins - Word MVP

Hi Rita,

Use:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2,}", MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Selection.Range.Style = "Strong"
Loop
End With
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="(I )([A-Z]{2,})", MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Selection.Range.Style = "Strong"
Loop
End With


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - 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