How do I find shaded text in a large document?

I am working with a large document with many tables and would like to find those cells which are shaded a particular color so I can edit them.  Is this possible?  If so, how?  The shade I'm seeking is a theme shade, not a custom one.  I use Office 2013 and Windows 8.1.  Thank you...
Edit them how?
The following macro will locate all cells with the same background shade as the selected cell and write some text (highlighted) into the cell (so don't test it on your original document!!!!)

Sub Macro1()
Dim oTable As Table
Dim oCell As Cell
Dim iCol As Long
    If Selection.Information(wdWithInTable) = True Then
        If MsgBox("Is the selected cell the required shade?", vbYesNo) = vbYes Then
            iCol = Selection.Cells(1).Shading.BackgroundPatternColorIndex
            For Each oTable In ActiveDocument.Tables
                For Each oCell In oTable.Range.Cells
                    If oCell.Shading.BackgroundPatternColorIndex = iCol Then
                        'Do what you want with the cell here e.g
                        oCell.Range.Text = "This cell has shading!"
                    End If
                Next oCell
            Next oTable
        End If
    Else
        MsgBox "Put the cursor in a cell of the colour you wish to process and run the macro again"
    End If
End Sub
Graham Mayor (Microsoft Word MVP 2002-2019)
For more Word tips and downloads visit my web site
https://www.gmayor.com/Word_pages.htm

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Er, um, well, thank you for all your work, but this is WAY beyond my technical ability.  All I know about macros is that they are a series of repeated actions.  What I was looking for was some way to search for cells of a particular color, so I could see what was in them, in the same way a search can be done for highlighted text.

But I do thank you for your time and effort to provide this answer, even if I don't have the expertise to use it...  :(
The answer is 42.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

What you require is not available. The macro will do what you need and is quite simple to employ - see http://www.gmayor.com/installing_macro.htm  

Put the cursor in a table cell of the required colour shading and run the macro. It will locate each cell from that point in turn and select it so that you can see the content, and then gives you the options to stop or continue to the next. When you wish to resume, leave the cursor in the cell you have stopped at and run the macro again. It will continue from that point.

I have modified it slightly so that you can do almost what you wish (see below).

Sub FindCellColor()
Dim oRng As Range
Dim oTable As Table
Dim oCell As Cell
Dim iCol As Long
    If Selection.Information(wdWithInTable) = True Then
        If MsgBox("Is the selected cell the required shade?", vbYesNo) = vbYes Then
            iCol = Selection.Cells(1).Shading.BackgroundPatternColorIndex
            Set oRng = Selection.Range
            oRng.End = ActiveDocument.Range.End
            For Each oTable In oRng.Tables
                For Each oCell In oTable.Range.Cells
                    If oCell.Shading.BackgroundPatternColorIndex = iCol Then
                        oCell.Select
                        If MsgBox("Edit this cell?", vbYesNo) = vbYes Then Exit Sub
                    End If
                Next oCell
            Next oTable
        End If
    Else
        MsgBox "Put the cursor in a cell of the colour you wish to process and run the macro again"
    End If
End Sub
Graham Mayor (Microsoft Word MVP 2002-2019)
For more Word tips and downloads visit my web site
https://www.gmayor.com/Word_pages.htm

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated August 11, 2023 Views 535 Applies to: