Skip to content

Instantly share code, notes, and snippets.

@cocomice
Last active September 9, 2025 07:41
Show Gist options
  • Select an option

  • Save cocomice/60edc2ac43eb510f6ad3ab5a39890aad to your computer and use it in GitHub Desktop.

Select an option

Save cocomice/60edc2ac43eb510f6ad3ab5a39890aad to your computer and use it in GitHub Desktop.
' 该宏脚本运行用户在修订模式下,“接收修订”后保留修订前后的格式(删除、不同颜色等)
Sub acceptChanges()
Dim oRev As Revision
For Each oRev In ActiveDocument.Revisions
If oRev.Type = wdRevisionInsert Then
oRev.Range.Font.Color = wdColorBlue
oRev.Accept
ElseIf oRev.Type = wdRevisionDelete Then
oRev.Range.Font.Color = wdColorRed
oRev.Range.Font.StrikeThrough = True
oRev.Reject
End If
Next
End Sub
Sub DeleteUnusedStyles()
Dim doc As Document
Dim s As Style
Dim styleInUse As Boolean
Dim rng As Range
Set doc = ActiveDocument
For Each s In doc.Styles
If Not s.BuiltIn Then
styleInUse = False
For Each rng In doc.StoryRanges
If rng.Find.Style = s Then
styleIn-use = True
Exit For
End If
Next rng
If Not styleInUse Then
s.Delete
End If
End If
Next s
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment