![]() |
#1
|
|||
|
|||
![]()
I'm writing a VBA macro that find any font color used except from black (RGB: 0,0,0) and blue.
If this macro finds a character that isn't black and blue in a paragraph, it shows the text of the paragraph with a message box. Code:
Option Explicit Sub test() Dim oParagraph As Paragraph, oLink As Hyperlink Dim char As Range Dim bFound As Boolean, i As Integer Dim strHex As String, strHex1 As String, strHex2 As String, strHex3 As String Dim strHex4 As String, strHex5 As String bFound = False For Each oParagraph In ActiveDocument.Paragraphs For Each char In oParagraph.Range.Characters strHex = Hex(char.Font.TextColor.RGB) strHex1 = Hex(char.Font.ColorIndex) strHex2 = Hex(char.Font.Color) strHex3 = Hex(char.Style.Font.Color) strHex4 = Hex(char.Style.Font.ColorIndex) strHex5 = Hex(char.Style.Font.TextColor.RGB) If char.Font.Color <> wdColorAutomatic And char.Font.Color <> wdColorBlack _ And char.Font.Color <> wdColorBlue Then bFound = True GoTo nt_lb End If Next char Next oParagraph nt_lb: If bFound = True Then MsgBox oParagraph.Range.Text End If End Sub When you execute this macro, this macro shows the pragraph including the hyperlink although the hyperlnk is blue and the remaining text is black in the paragraph. My macro checks the following properties for getting the correct font color:
But, any of the above properties don't return the correct color (blue). In the hyperlink text "This is a test link.", this macro finds that the first "T" character isn't black and blue. Also, I've attached a sample document. Please help me. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to change an RGB table cell shading color to another RGB color | David Matthews | Word VBA | 4 | 05-29-2018 02:45 PM |
Correct Bookmark Hyperlink | Phil H | Word | 2 | 02-10-2016 12:55 PM |
![]() |
cyberpaper | Word | 2 | 01-03-2013 02:07 PM |
Word macro to email hyperlink | pooley343 | Word VBA | 0 | 07-20-2011 01:48 AM |
![]() |
Henry | Word | 1 | 07-05-2011 04:29 PM |