View Full Version : How to change the color of special Characters
Rakesh
07-21-2010, 11:27 AM
:anyone:
Hi Rocks,
Through Coding Can it Possible to find and change the color of special characters, such as ®, ™, © etc.
If so please help.
Thanks in advance
:banghead: Rakesh
gmaxey
07-21-2010, 02:22 PM
Each of those characters has a ASC number which you can find by selecting the text and running the following line of code in the VBE Immediate window:
Msgbox Asc(Selection.Text)
Using those codes you can then:
Sub ScratchMaco()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = Chr(174)
While .Execute
oRng.Font.Color = wdColorRed
Wend
End With
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = Chr(153)
While .Execute
oRng.Font.Color = wdColorRed
Wend
End With
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = Chr(169)
While .Execute
oRng.Font.Color = wdColorRed
Wend
End With
End Sub
Rakesh
07-21-2010, 03:35 PM
:mbounce2:
Hi gmaxey,
Thanks a Ton for your kind reply.
Its working Fine
:beerchug: Rakesh
fumei
07-22-2010, 10:58 AM
As all your special characters are ASC > 127, you may also want to try something:
Dim oChar
For Each oChar In ActiveDocument.Range.Characters
If Asc(oChar) > 127 Then
oChar.HighlightColorIndex = wdRed
End If
Next
Rakesh
07-23-2010, 05:55 PM
Hi Fumei,
Thanks for your kind reply. Its working fine, but it looks like a background color. How to color the text?
Thanks
Rakesh
:beerchug:
gmaxey
07-23-2010, 07:31 PM
The same as we did before:
Sub ScratchMaco()
Dim oChar
For Each oChar In ActiveDocument.Range.Characters
If Asc(oChar) > 127 Then
oChar.Font.Color = wdColorRed
End If
Next
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.