how to find, select and change colour of words in table (VBA) ?

P

Peter

Hello

I have one table with words (YES) or (NO). I'd like to write VBA code which
could find, select and change colour to red of (YES) words in table.
Could you help me to write VBA code with it ?
I'm looking forward to your replies.

Regards

Peter
 
D

Dave Lett

Hi Peter,

You can use something like the following:

Dim oRng As Range
'''set a placeholder for the current selection
'''at the end of the routine re-selec the current
'''selection
Set oRng = Selection.Range
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "Yes"
Do While .Execute
If Selection.Information(wdWithInTable) Then
Selection.Font.Color = wdColorRed
End If
Loop
End With
End With
'''re-select the original selection
oRng.Select

HTH,
Dave
 

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