![]() |
|
#5
|
|||
|
|||
|
Hi again,
Well, it turns out I need to exclude spaces and other characters when looking for any different font colors... so the two-liner bit, as excellent as it is - is too "document-generic" for me. I thought about going at it this way, using the find command (the code below is a crude version of what I'm after): Outline (just to be clear of what I was trying to achieve in plain English, in case I missed something code-wise): 1. Go to the first character in the document 2. Search for that color font (grab and use the first character's font color as criteria) using find while ignoring spaces 3. Check if find bumps into any different color other than that of which is being searched (if find.found=false I think...) Code:
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Font.Color = Selection.Font.Color
With Selection.Find
.Text = "*[! ]"
.Font.Color = Selection.Font.Color
.MatchWildcards = True
.Wrap = wdFindContinue
.Format = True
.Forward = True
.Execute
End With
If Selection.Find.Found = False Then MsgBox "Found another color." _
Else MsgBox "Did not find any other color."
I'm not sure what to do next. Any ideas on how to improve this? Thanks, |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
VBA change font color to background color
|
donaldadams1951 | Word VBA | 6 | 05-31-2018 04:36 PM |
| Advanced Font Color Manipulation In Word: Inserting another color than the surrounding text | stuartg | Word | 1 | 02-20-2017 12:38 AM |
Remove white text background (keeping the font color and page color intact
|
cc3125 | Word | 1 | 10-26-2015 06:44 PM |
| Font Color Question//.Replacement.Font.Color = 12611584 | rsrasc | Word VBA | 3 | 09-05-2015 09:03 PM |
| Make a certain font face and font color as default in a document. | Singh_Edm | Word VBA | 2 | 09-13-2014 08:47 PM |