Share via

how to get Word VBA editor to interpret Traditional Chinese Characters?

Edward Evans 20 Reputation points
2026-04-02T13:49:53.68+00:00

I am trying to write a Word macro to arange a vocabulary list for a document written in Traditional Chinese characters. I open the document with Documents.Open, using ChineseTraditionalBig5 encoding. Document opens and looks fine, but when VBA code assigns characters to a text variable, it only shows up in VBA editor as "????", and using that to search for occurrences of same "word" in another document always fails. What else do I need to do for the code to be able to find other occurrences of this text fragment?


Moved from Developer technologies | Visual Basic for Applications

Microsoft 365 and Office | Word | Other | Windows

2 answers

Sort by: Most helpful
  1. Kal-D 7,180 Reputation points Microsoft External Staff Moderator
    2026-04-02T19:26:53.64+00:00

    Hi Edward Evans,

    What you’re seeing is often related to how the VBA editor displays certain characters, rather than an indication that the text itself is incorrect or unusable. In Word VBA, Chinese text can still be stored and handled correctly even if the VBA editor shows it as ????.

    The more likely reasons your search fails are:

    • Paragraph.Range.Text includes hidden end characters, not just the visible text. Besides the paragraph mark (vbCr / Chr(13)), Word can also include Chr(7) as an end‑of‑cell marker when the paragraph is inside a table. If you don’t remove those, the search text won’t match.
    • The .Find object keeps previous settings unless you reset it. That can cause searches to fail silently if formatting, wildcards, or other options were left enabled from an earlier search.

    Also, because your source file is a .docx, Encoding:=msoEncodingTraditionalChineseBig5 is usually not the deciding factor here. That parameter is more relevant when opening encoded text files, not standard Word documents.

    Try this pattern instead:

    Dim sDefinition As String
    Dim rngFind As Range
    sDefinition = VocabDoc.Paragraphs(i).Range.Text
    sDefinition = Replace$(sDefinition, vbCr, "")
    sDefinition = Replace$(sDefinition, Chr$(7), "")
    sDefinition = Trim$(sDefinition)
    Set rngFind = TargetDoc.Content
    With rngFind.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = sDefinition
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = False
        .MatchCase = False
        .MatchWholeWord = False
        .Execute
    End With
    ``
    

    A few important points:

    • Don’t rely on the VBA editor or Watch window to verify Traditional Chinese text, since the editor may not visually render those characters even when Word is handling them correctly.
    • To confirm whether the string is really present, use .Find.Execute, Len, AscW, and actual search results rather than the editor display.
    • Strip both vbCr and Chr(7) before searching.
    • Reset .Find each time with .ClearFormatting and .Replacement.ClearFormatting.

    You probably don’t need another encoding conversion step. The main fixes are removing Word’s hidden end‑of‑paragraph/end‑of‑cell characters and resetting the Find object before each search.

    Please let me know if this proves useful to you, or if you would like further assistance.

    I'm looking forward to your reply.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment”.   

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Q&A Assist
    2026-04-02T13:50:09.0933333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    VBA itself works internally as Unicode, but support for Traditional Chinese in identifiers and string handling depends on the system locale and the Office/VBA implementation.

    From the specification:

    • VBA modules are defined as if encoded in Unicode; the mapping to the actual system encoding is implementation-defined.
    • Traditional Chinese identifiers in VBA are based on Windows Codepage 950 (Big5). Characters are mapped between CP950 and Unicode via the bestfit950.txt mapping.

    When the VBA editor shows "????" for a string that contains Traditional Chinese characters, it indicates that the current environment (system locale / VBA editor / font) cannot represent those characters correctly in the code page it is using. As a result, the string literal or variable content is not preserved correctly, so searches using that text will fail.

    To make the macro work with Traditional Chinese text:

    1. Ensure the system and Office installation support the Traditional Chinese locale and fonts.
    2. Use Unicode-based text handling (which VBA does internally) and avoid relying on a non-Unicode code page that cannot represent the characters.
    3. If using APIs or conversions such as VbStrConv.TraditionalChinese, run the code only on a system that supports the Traditional Chinese locale; otherwise, the operation will fail with an error like “This system does not contain support for the Traditional Chinese locale.”

    If the current machine does not support the Traditional Chinese locale, the reliable fix is to upgrade or move the macro to a machine that does, so that the CP950↔Unicode mapping and display of Traditional Chinese characters work correctly and the VBA editor no longer collapses them to "????".


    References:

    0 comments No comments

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.