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

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

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