Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-05-2021, 11:51 PM
LQuinn LQuinn is offline find/replace all text not a specific colour? Windows 10 find/replace all text not a specific colour? Office 2019
Novice
find/replace all text not a specific colour?
 
Join Date: Jan 2021
Location: Western Australia
Posts: 20
LQuinn is on a distinguished road
Default find/replace all text not a specific colour?

hi all, wondering if it's possible to use find/replace to manage font colours?

i'm wanting to find all text that isn't a specific RGB, and then depending on where it is in the document, set it to the standard RGB

this is what i have so far which does work, i'm just wondering if this is possible with find/replace in a range, or if there is a better way?

thanks!

Code:
Private Sub Get_Non_Grey_Font_Colour()
'
' affects ALL document content - ignores tables and charts
'
' find text not in 80% grey
'
    Dim objPara As Paragraph
    Dim lng80PercentGrey As Long
    Dim rngTemp As Range
    lng80PercentGrey = RGB(80, 84, 77)
    
    For Each objPara In ActiveDocument.Paragraphs
        If objPara.Range.Font.TextColor <> lng80PercentGrey Then
            objPara.Range.Select
            If Selection.Information(wdWithInTable) Then
                Set rngTemp = Selection.tables(1).Range
                rngTemp.Collapse wdCollapseEnd
                rngTemp.Select
            Else
                objPara.Range.Select
                objPara.Range.Font.TextColor = lng80PercentGrey
            End If
        End If
    Next objPara
    
    Set objPara = Nothing
    Set rngTemp = Nothing

    Debug.Print Now & " - " & "finished!"
End Sub

Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
find/replace all text not a specific colour? How do I select all text highlighted in a specific colour? bertietheblue Word 2 04-15-2016 12:30 PM
find/replace all text not a specific colour? Find/replace font colour in all header/footer trillium Word VBA 4 10-20-2015 10:39 PM
find/replace all text not a specific colour? VBA Table – Search All Tables - Find & Replace Text in Table Cell With Specific Background Color jc491 Word VBA 8 09-30-2015 06:10 AM
Word VBA Find Table Text Shading Colour and replace with another QA_Compliance_Advisor Word VBA 10 09-19-2014 08:36 AM
find/replace all text not a specific colour? Quickest way to change text to Arial size 11 specific colour BlueClearSky Word 6 11-22-2013 03:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:22 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft