![]() |
#2
|
||||
|
||||
![]()
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 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
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ajanson | Word | 3 | 08-15-2016 04:49 PM |
![]() |
DougsGraphics | Word VBA | 2 | 06-24-2015 07:31 AM |
![]() |
tluken | Word | 1 | 08-23-2012 10:20 AM |
![]() |
WilltheGrill09 | Word | 1 | 03-27-2012 02:44 AM |
![]() |
b0x4it | Word | 4 | 05-18-2011 07:54 PM |