![]() |
#1
|
|||
|
|||
![]()
I want to determine the range for all shaded (not highlighted) text in my document. The problem is that I don't know the colors of all the shades used. I've written some code to find those colors and their ranges, but it's messy and doesn't work well (see below). I have hundreds of documents I want to do this with.
I've read that typing CTRL-a, CTRL-q, CTRL-spacebar will remove all direct formatting, and when I do this all shades in the document disappear. I conclude they must all be direct formatting. This suggests they are not "styles" vba objects, and yet the Style listing of the user interface has entries for every shading (and other formatting). The screenshot shows part of the document with the Styles and Style Inspector. I put my cursor on the word 'big' and then used the 'select all 154 instances" -- here the selected words show as gray, but the Style Inspector shows "Pattern: Solid (100%) (White)". But if I put my cursor in the pink text 'bar', I see "Pattern: Solid (100%) (Custom Color(RGB(255,191,255)))" I'm not interested in the White shaded text, but I am interested in all other colors. This Style list interface provides great control, but I need to use vba since I have many large, complex documents like this. I've literally spent days on this and would appreciate any help. here's some of the code I mentioned above: Code:
Set wR = wDoc.Content wR.Find.ClearFormatting wR.Find.Font.Shading.BackgroundPatternColor = wdColorAutomatic Set wF = wR.Find With wF .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = True End With Do While wF.Execute = True ...[lots of code]... Loop Last edited by Tony; 04-07-2021 at 11:28 PM. Reason: added link to screenshot |
|
![]() |
||||
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 |