Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-10-2022, 06:42 AM
eg0n eg0n is offline Remove shading of specific color from document with multiple shading colors Windows 10 Remove shading of specific color from document with multiple shading colors Office 2021
Novice
Remove shading of specific color from document with multiple shading colors
 
Join Date: Aug 2022
Posts: 2
eg0n is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 08-10-2022, 04:12 PM
Guessed's Avatar
Guessed Guessed is offline Remove shading of specific color from document with multiple shading colors Windows 10 Remove shading of specific color from document with multiple shading colors Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #3  
Old 08-11-2022, 12:42 AM
eg0n eg0n is offline Remove shading of specific color from document with multiple shading colors Windows 10 Remove shading of specific color from document with multiple shading colors Office 2021
Novice
Remove shading of specific color from document with multiple shading colors
 
Join Date: Aug 2022
Posts: 2
eg0n is on a distinguished road
Default

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
Reply With Quote
Reply

Tags
color, selection, shading



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove shading of specific color from document with multiple shading colors 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
Remove shading of specific color from document with multiple shading colors 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
Remove shading of specific color from document with multiple shading colors How to apply formatting(color & shading) to specific letters in whole doc. (arabic) loopseye Word 3 08-05-2013 10:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:15 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft