1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VBA and Word 2010: Trying to identify text by RGB colour and delete it.

Discussion in 'Business Applications' started by BrigitteAlaimo, Mar 7, 2013.

Thread Status:
Not open for further replies.
  1. BrigitteAlaimo

    BrigitteAlaimo Thread Starter

    Mar 7, 2013
    Tech Support Guy System Info Utility version
    OS Version: Microsoft Windows 7 Enterprise, Service Pack 1, 64 bit
    Processor: Intel(R) Core(TM) i5 CPU U 520 @ 1.07GHz, Intel64 Family 6 Model 37 Stepping 5
    Processor Count: 4
    RAM: 3891 Mb
    Graphics Card: Intel(R) HD Graphics, 1721 Mb
    Hard Drives: C: Total - 305142 MB, Free - 243716 MB;
    Motherboard: LENOVO, 2985F8G
    Antivirus: ESET NOD32 Antivirus 4.2, Updated and Enabled


    I hope you can help me.

    I am trying to find a VBA code to identify text by its RGB colour, and then delete it from the document. With this in mind, I am currently trying to edit a code I found online which changes text from black RGB (0,0,0) to red RGB (255,0,0). I thought I could use the same concept but to just delete the black text instead of changing it’s colour.

    I am a beginner and it is just not that simple for me. Does anyone have any suggestions?

    Thanks in advance! :)

  2. XCubed


    Feb 21, 2013

    You can do this using the in-built Find/Replace in Word.

    click on Replace
    click on "Format" (at the bottom of the replace screen)
    Click on "Font"
    Click on "Font Colors"
    Click on "Custom"
    Change the RGB settings to 0,0,0
    Click on OK twice
    Click in the "Replace" box
    Click "Replace All"

    You can record all of these steps in a Macro

    Sub Macro1()
    ' Macro1 Macro
        Selection.Find.Font.Color = wdColorBlack
        With Selection.Find
            .Text = ""
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    Try either of these on a copy of your document in case something goes horribly wrong.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1092173

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice