What is the aim of this exercise? If as your code implies you simply want to remove the shading then
Code:
Sub RemoveShading()
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
oStory.Font.Shading.BackgroundPatternColor = wdColorAutomatic
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Font.Shading.BackgroundPatternColor = wdColorAutomatic
Wend
End If
Next oStory
lbl_Exit:
Set oStory = Nothing
Exit Sub
End Sub
should do the job.
It is possible that there are story ranges that are not covered by the above code, but it will cover the ranges in most documents.
You could use the code as a custom process in conjunction with
Document Batch Processes to remove the shading from all your documents, with just a minor change:
Code:
Sub RemoveShading(oDoc)
Dim oStory As Range
For Each oStory In oDoc.StoryRanges
oStory.Font.Shading.BackgroundPatternColor = wdColorAutomatic
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Font.Shading.BackgroundPatternColor = wdColorAutomatic
Wend
End If
Next oStory
lbl_Exit:
Set oStory = Nothing
Exit Sub
End Sub
If you just want to identify the colours used, investigate the
ColorCop utility which will identify any selected colour.