MatchWholeWord 是 Word VBA 中的一个属性,用于指定是否要在查找时仅匹配整个单词。如果设置为 'True',则只会匹配整个单词,否则将匹配包含该单词的任何字符串。以下是一个示例:

Sub FindWholeWord()
    With ActiveDocument.Content.Find
        .ClearFormatting
        .Text = 'hello'
        .MatchWholeWord = True '只匹配整个单词
        .Execute
    End With
End Sub

在上面的代码中,我们将 MatchWholeWord 属性设置为 'True',因此只会匹配单独的 'hello' 单词,而不是包含 'hello' 的任何字符串。

Word VBA 中的 MatchWholeWord 属性:仅匹配整个单词

原文地址: https://www.cveoy.top/t/topic/nZDi 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录