View Single Post
 
Old 04-05-2021, 11:51 PM
LQuinn LQuinn is offline Windows 10 Office 2019
Novice
 
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