Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Delete all shading

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rhamre@citation.com - 09 Feb 2006 15:39 GMT
Alright, now... i only ask questions when i really need help... so here goes.

I have documents that have all this highlighting to help notify people of
issues that may or may not be problematic, so i have this-

Sub RemoveHighlights()
   
   Dim rngSearch As Word.Range
       
   Application.ScreenUpdating = False
   
   Set rngSearch = ActiveDocument.Range
   
   rngSearch.Find.ClearFormatting
   rngSearch.Find.Replacement.ClearFormatting
   
   With rngSearch.Find
       .Format = True
       .highLight = True
       .Replacement.highLight = False
       .Execute Replace:=wdReplaceAll
   End With
   
   Application.ScreenUpdating = True
   
End Sub

Well, i get a document, and it turns out a programmer has added shading, not
highlighting.

I've tried all kinds of things to delete shading using a range, and i can't
figure it out. I searched through past threads and didn't find anything also.

If anyone could help it'd be much appreciated.

Thanks guys.
Dave Lett - 09 Feb 2006 16:41 GMT
Hi,

I think you can use something like the following:

With ActiveDocument.Range
   .HighlightColorIndex = wdNoHighlight
   .Shading.BackgroundPatternColorIndex = wdNoHighlight
End With

HTH,
Dave

> Alright, now... i only ask questions when i really need help... so here goes.
>
[quoted text clipped - 32 lines]
>
> Thanks guys.
Chuck Henrich - 09 Feb 2006 16:49 GMT
If you want to remove *all* shading and  highlighting, you could use the
following instead of find/replace:

With ActiveDocument.Range
   With .Font.Shading
       .Texture = wdTextureNone
       .ForegroundPatternColor = wdColorAutomatic
       .BackgroundPatternColor = wdColorAutomatic
   End With
   .HighlightColorIndex = wdNoHighlight
End With

Alternatively you could loop through all the paragraphs (or even words) in
your document looking for a particular shading background color or background
color index and replacing it with 0 (for wdColorAutomatic), eg:

Dim p As Paragraph

For Each p In ActiveDocument.Paragraphs
   'XX = index number or constant for the shading
   'you want to remove
   If p.Range.Font.Shading.BackgroundPatternColorIndex = XX Then
       p.Range.Font.Shading.BackgroundPatternColorIndex = 0
   End If
Next p

You can also set your criteria to background color, foreground color/color
index, texture, etc.

HTH

Signature

Chuck Henrich
www.ProductivityApps.com
Stylist Style Generator - automatically create and define sets of paragraph
numbering and heading styles

> Alright, now... i only ask questions when i really need help... so here goes.
>
[quoted text clipped - 32 lines]
>
> Thanks guys.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.