View Single Post
 
Old 08-17-2023, 02:37 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

Hi again! Unfortunaltely, from the very beginning it was not clear that the document had a page filling color. After the misunderstanding has been corrected, here's the code that seems to work:

Code:
Sub Deshading()

Dim oPara As Paragraph
'If the selection includes tables, error 4605 will be returned.
'Thus, an error handler is needed:
On Error Resume Next

Application.ScreenUpdating = False
    For Each oPara In ActiveDocument.range.Paragraphs
        oPara.range.Select
        If Not selection.Shading.BackgroundPatternColor = wdColorAutomatic Then
            selection.Shading.BackgroundPatternColor = wdColorAutomatic
        End If
    Next oPara
Application.ScreenUpdating = True
End Sub

Last edited by vivka; 08-17-2023 at 09:53 PM.
Reply With Quote