Dim app As New MSWord.Application
try
Dim fileName = ProjectPath & "待批注文件.docx"
Dim doc As object = app.Documents.Open(fileName)
For Each dr As DataRow In DataTables("词库").Select("", "英文 desc")
Dim count = Doc.Characters.Count
Dim rng As MSWord.Range = Doc.Range(Start:=0, End:=count)
rng.Find.ClearFormatting()
rng.Find.Forward = True
rng.Find.Text = dr("英文")
rng.Find.Execute()
Do While rng.Find.Found = True
rng.Comments.Add(Range:=rng,Text:=dr("中文"))
'app.Selection.TypeText(Text:=dr("中文"))
rng.Find.Execute()
Loop
Next
app.visible = True
catch ex As exception
msgbox(ex.message)
finally
'app.Quit
End try