【诉求】VC中如何对word文档中指定的一个字符串设置格式,比如标红查了很多帖子,只找到对整个段落进行设置格式,比如这个帖子 http://www.doc88.com/p-739755206133.html但是我现在需要对一个word文档中的某个指定的关键字,或者搜索到的关键字标识出来,应该怎么实现。比如:“假设这是一个word文档的正文”谢谢!

解决方案 »

  1.   

    录了个宏,但是看这个宏里面用到了selection的Find函数,但是在VC里面定义的selection类型变量没有这个函数,也没看到实现类似查找功能的函数。请问是我哪里些错了吗?应该如何更正。谢谢!录制的宏如下:
    '
        Selection.Find.ClearFormatting
        With Selection.Find
            .Text = "辅导"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchByte = True
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute
        Selection.Font.Color = wdColorRed
        Selection.Find.ClearFormatting
        With Selection.Find
            .Text = "辅导"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchByte = True
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
    End Sub