Word VBA: Finding text with a particular color.

Can someone give me code to get the font color at the current cursor position and then look for the next text with the same color?
LVL 43
Saqib Husain, SyedEngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try
Sub Macro()
With Selection
    lngCol = .Font.Color
    With .Find
        .ClearFormatting
        .Font.Color = lngCol
        .Text = ""
        .Forward = True
        .Format = True
        .Execute
    End With
End With

End Sub

Open in new window

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HuaMin ChenProblem resolverCommented:
Here is an example to get font color

Worksheets("Code Sheet").Cells(i, 1).Font.Color

Open in new window

Here is one other example to find out one specific string

    Set c1 = Worksheets("Code Sheet3").Cells.Find(Para_Country)

    If Not c1 Is Nothing Then
        Worksheets("Budget-Report-HO").Cells(3, 5).Value = Worksheets("Code Sheet3").Cells(c1.Row, 2).Value
    Else
        Exit Sub
    End If

Open in new window

0
Rgonzo1971Commented:
@HuaMinChen Word VBA not Excel VBA
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Saqib Husain, SyedEngineerAuthor Commented:
Just perfect, thanks.
0
Rgonzo1971Commented:
Word or Excel I'm confused...
0
Saqib Husain, SyedEngineerAuthor Commented:
Sorry, wrong answer accepted. I cannot find the request attention button.
0
Rgonzo1971Commented:
Maybe the flag "report"
0
Saqib Husain, SyedEngineerAuthor Commented:
Yes, I already did that.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.