You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何实现Word修订内容及所在整句高亮的宏?

高亮Word修订内容及所在完整句子的VBA宏

这个宏可以实现以下功能:

  • 高亮文档中所有插入/删除类修订内容
  • 同时高亮包含这些修订内容的完整句子(句子以大写字母开头,以句号、冒号、问号、感叹号、逗号或分号结尾)

完整VBA代码

Public Sub Highlight_trackchange()

Dim doc As Word.Document
Dim rng As Word.Range
Dim rev As Word.Revision

Set doc = Word.ActiveDocument

For Each rev In doc.Revisions

If rev.Type = wdRevisionDelete Or rev.Type = wdRevisionInsert Then

Set rng = rev.Range

Do While rng.Start < rng.End

If rng.Start.Text.IsLetter Then

Do While rng.End.Character.IsNotOneOf(vbCrLf, vbQuestion, vbExclamation, vbPeriod, vbColon, vbSemicolon, vbComma)

rng.HighlightColorIndex = wdYellow

rng.MoveRight Unit:=wdCharacter, Count:=1

Loop

End If

rng.MoveRight Unit:=wdCharacter, Count:=1

Loop

End If

Next rev

End Sub

内容的提问来源于stack exchange,提问作者akki

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 04:28:13