Search for specific terms and change whole sentence

C

Cameron

Hi,
I'm writing some technical documents and there are many formatting
conventions to obey the standards.

I think i could make some efficiency gains by making a marco do the following

IF sentence contains
"will display"
"will be saved"
THEN change full sentence to Italics
END IF

Further to this, and not sure how to achieve i'd like the macro to run in
the background, so that the sentence with the declared terms changes when the
full stop is placed.

Is this possible?????

Appreciate any assistance / cmments
 
G

Graham Mayor

The macro is easy enough:

Dim oRng As Range
Dim vFindText
Dim i As Long
vFindText = Array("will display", "will be saved")
For i = 0 To UBound(vFindText)
With Selection
.HomeKey wdStory
With .Find
.Text = vFindText(i)
Do While .Execute(Forward:=True) = True
Set oRng = Selection.Range
oRng.Sentences(1).Italic = True
Loop
End With
End With
Next i

but running it automatically when you place the full stop is not. Run from a
toolbar button
http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
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