View Single Post
 
Old 05-25-2018, 08:10 PM
jjfreedman jjfreedman is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: May 2012
Location: https://jay-freedman.info
Posts: 39
jjfreedman is on a distinguished road
Default

If the shading you want to change really is table cell shading, then (a) it is not .Font.Shading and (b) you can't use Range.Find to locate it. [There are three possible kinds of shading in a table cell, controlled by the dropdown in the Shading page of the Borders & Shading dialog: Text, Cell, and Table. In VBA each of them is addressed differently.]

This macro iterates through all the cells of each row of each table in the document and makes the change when it finds the proper color of Cell background shading.

Code:
Sub test()
    Dim tbl As Table
    Dim rw As Row
    Dim cel As Cell
    
    For Each tbl In ActiveDocument.Tables
        For Each rw In tbl.Rows
            For Each cel In rw.Cells
                If cel.Shading.BackgroundPatternColor = RGB(225, 225, 153) Then
                    cel.Shading.BackgroundPatternColor = RGB(225, 225, 225)
                End If
            Next cel
        Next rw
    Next tbl
End Sub
Reply With Quote