A family of Microsoft word processing software products for creating web, email, and print documents.
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.Textincludes hidden end characters, not just the visible text. Besides the paragraph mark (vbCr/Chr(13)), Word can also includeChr(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
.Findobject 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
vbCrandChr(7)before searching. - Reset
.Findeach time with.ClearFormattingand.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.