Share via

Change color of Hebrew cantillation characters

joe lewis 40 Reputation points
2026-06-02T21:42:52.3833333+00:00

Word options (Advanced) allow me to change color of all diacritics. I would like to change all diacritics to green and then change cantillation marks to red. Cantillation marks are Hex 0591-05AE, or Dec 1425-1454. I wonder if this can be done by ctrl-H, to search for that range of characters and then replace with red. But [^u0591-^u05AE] gives an error, so I don't know how to enter the search term and which other options to switch on or off (wildcards, match diacritics, etc.) I have tried VBA but am not sure how to enter the search term in VBA. Thanks for any help!

Developer technologies | Visual Basic for Applications

Answer accepted by question author

Jack Dang (WICLOUD CORPORATION) 18,970 Reputation points Microsoft External Staff Moderator
2026-06-03T03:29:58.8966667+00:00

Hi @joe lewis ,

Thanks for reaching out.

Word can search for a single Unicode character using ^u, but it does not support searching for a range of Unicode values in one expression, such as 0591-05AE. Also, ^u uses decimal values, not hexadecimal values, so U+0591 would be searched as ^u1425, not ^u0591.

Word's wildcard engine also does not support Unicode character classes or ranges in the same way that regular expression engines do, so this is not something that can be done with one wildcard Find/Replace pattern.

The suitable way to handle this is with a small VBA macro. The macro below first colors the Hebrew combining marks green, then colors the cantillation marks red afterward. The cantillation range is included in the earlier green pass and then recolored red in the second pass, so the final color for those marks will be red.

I would suggest testing this on a copy of the document first. The code snippets below are provided as reference, so please adjust the ranges, colors, or target document areas as needed for your specific document:

Option Explicit

Sub ColorHebrewDiacriticsAndCantillation()
    Application.ScreenUpdating = False

    ' Hebrew combining marks: accents, points, dots, etc.
    ApplyColorToCodeRange &H591, &H5BD, wdColorGreen
    ApplyColorToCodeRange &H5BF, &H5BF, wdColorGreen
    ApplyColorToCodeRange &H5C1, &H5C2, wdColorGreen
    ApplyColorToCodeRange &H5C4, &H5C5, wdColorGreen
    ApplyColorToCodeRange &H5C7, &H5C7, wdColorGreen

    ' Hebrew cantillation marks U+0591 through U+05AE.
    ApplyColorToCodeRange &H591, &H5AE, wdColorRed

    Application.ScreenUpdating = True
End Sub

Private Sub ApplyColorToCodeRange(ByVal firstCode As Long, _
                  ByVal lastCode As Long, _
                  ByVal markColor As WdColor)
    Dim story As Range
    Dim currentStory As Range
    Dim codePoint As Long

    For Each story In ActiveDocument.StoryRanges
        Set currentStory = story

        Do While Not currentStory Is Nothing
            For codePoint = firstCode To lastCode
                ApplyColorToOneCharacter currentStory, ChrW$(codePoint), markColor
            Next codePoint

            Set currentStory = currentStory.NextStoryRange
        Loop
    Next story
End Sub

Private Sub ApplyColorToOneCharacter(ByVal storyRange As Range, _
                   ByVal searchChar As String, _
                   ByVal markColor As WdColor)
    Dim searchRange As Range
    Set searchRange = storyRange.Duplicate

    With searchRange.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = searchChar
        .Replacement.Text = "^&"
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Replacement.Font.Color = markColor
        .Execute Replace:=wdReplaceAll
    End With
End Sub

For this approach, leave wildcards off. The macro is not using Word wildcard syntax; it is simply going through each Unicode character in the range and applying the requested font color. Because it runs a separate find operation for each character in the range, it may take some time on very large documents.

One small note: U+0591 through U+05AE is decimal 1425 through 1454. If you also need to include U+05AF, you can change this line:

ApplyColorToCodeRange &H591, &H5AE, wdColorRed

to this:

ApplyColorToCodeRange &H591, &H5AF, wdColorRed

Hope this helps! If my explanation and the information I provided were helpful, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.

Was this answer helpful?

1 person found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. joe lewis 40 Reputation points
    2026-06-09T13:24:08.3866667+00:00

    Jack gave me VBA samples to investigate this question further. Some fonts allow for coloring a specific diacritic in a different color (EzraSILSR), others (Narkisim) don't, so even if you apply a color to a specific diacritic it may not help. You can select the diacritic in your Word document and use Font options to change color, and see that some fonts change the color and others don't. Amazing!

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. AI answer

    2026-06-02T21:43:03.4933333+00:00

    Word’s built‑in Find/Replace and the documented add‑in search notation do not support searching by a Unicode range such as U+0591–U+05AE, and there is no syntax like [^u0591-^u05AE] available. The special-character search codes that Word understands are limited to items like paragraph marks, tabs, and a few generic patterns (any character, any digit, any letter), not arbitrary Unicode ranges.

    From the available information, only these kinds of special notations are supported in Word search logic:

    • ^? – any character
    • ^# – any digit
    • ^$ – any letter
    • Plus specific layout/markup characters such as ^p (paragraph mark), ^t (tab), ^l (manual line break), ^m (manual page break), etc.

    Because of this limitation:

    • A direct Ctrl+H search for “all characters from U+0591 to U+05AE” is not possible using Word’s standard Find/Replace syntax.
    • The same limitation applies to VBA’s Find.Text pattern: the documented special-character codes do not include a way to express a Unicode range.

    To color cantillation marks differently from other diacritics, a solution would have to explicitly target each relevant code point (for example, via a custom VBA macro that loops through characters and checks their code values) rather than relying on a single range expression in Find/Replace. That approach is not described in the provided material, and there is no documented built‑in option to assign a separate color to just the cantillation subset of Hebrew diacritics.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.