|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Remove shading of specific color from document with multiple shading colors
Hi!
I have tried searching this forum and the web without finding a working answer on my VBA related issue. What I would like to do is: Within a document different shading colours are used (paragraph shading) to mark-up text. I would like a macro to select and/or remove the shading of a specific color while leaving the text marked with other colors untouched. Furthermore colors are not standard colors so it needs to be able to remove shading of only a specific RGB code. Have anyone come across a solution that might help me? from what I've gathered based on my limited experience and hours of frustrating trial&error the mein issue is selecting only text with a specific background shading color. Any help at all will be greatly appreciated. Best regards |
#2
|
||||
|
||||
This might get you started - select a paragraph and run the macro to remove the shading from paragraphs with that same colour.
Note: Your results might vary according to how the colours are applied. In my quick testing the macro was greedy and removed colours from other paragraphs that were coloured from the same row of the colour palette (ie same tint level). It worked fine if the colours came from other levels of tint or were defined in RGB. Code:
Sub Macro2() Dim iCol As Long iCol = Selection.Shading.BackgroundPatternColor With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .Text = "" .ParagraphFormat.Shading.BackgroundPatternColor = iCol .Replacement.ParagraphFormat.Shading.BackgroundPatternColorIndex = wdWhite .Execute Replace:=wdReplaceAll End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Thank you! Seems like a clever workaround that also solves the issue of defining correct rgb, in my case the greedy part isn't an issue since they're all different tints but good to know I'll give it a testrun immediately!
Best regards |
Tags |
color, selection, shading |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Remove shading in numbered headings | Marcia | Word | 3 | 08-21-2020 10:54 AM |
Color and Transparency in Word Table shading | mikejvir | Word Tables | 2 | 07-14-2020 08:48 AM |
Can't apply shading to multiple sentences | alex100 | Word VBA | 5 | 06-10-2020 09:31 AM |
Macro to change an RGB table cell shading color to another RGB color | David Matthews | Word VBA | 4 | 05-29-2018 02:45 PM |
How to apply formatting(color & shading) to specific letters in whole doc. (arabic) | loopseye | Word | 3 | 08-05-2013 10:49 PM |