Thread: [Solved] vba control of shading
View Single Post
Old 04-08-2021, 05:41 PM
Tony Tony is offline Windows 10 Office 2019
Join Date: Apr 2021
Posts: 12
Tony is on a distinguished road

Thank you, macropod, for your code. I tried it on the test.docx I provided and it seems to work for the first line.

But then it seems to get stuck in this loop when it hits a particular wdColorAutomatic

Do While .End < Rng.End - 1
              If .Characters.Last.Next.Font.Shading.BackgroundPatternColor = _
                .Characters.First.Font.Shading.BackgroundPatternColor Then
                .End = .End + 1
                Select Case .Font.Shading.BackgroundPatternColor
                  Case wdColorAutomatic
                  Case wdColorWhite: .Collapse wdCollapseEnd
                  Case Else
                End Select
Reply With Quote