我需要为 Microsoft Word 文档中的每个单词添加正确的重音符号。我有一个名为“DoAccentuate”的脚本,它确定输入的任何单词的正确重音。但是,我不知道如何捕获当前选择的找到的单词,用我的 DoAccentuate 脚本处理它,然后用结果替换同一个单词(不影响文本的格式)。这是我尝试过的。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim document As Word.Document
document = Globals.ThisAddIn.Application.ActiveDocument
Dim FindObject As Word.Find = document.Application.Selection.Find
With FindObject
.ClearFormatting()
.Text = "<*>"
.MatchWildcards = True
.Replacement.ClearFormatting()
.Replacement.Text = DoAccentuate(document.Application.Selection.Text)
.Execute(Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll)
End With
End Sub