在日常办公或写作过程中,我们经常会遇到需要在 Word 文档中查找或删除重复文本的情况。本文将介绍几种实用的方法,帮助你高效完成这一任务。
这是最基础的方式:
Ctrl + F 打开查找面板。通过启用通配符,可以更灵活地匹配重复段落:
Ctrl + H)。([!^13]@)^13\1 可尝试查找连续重复行(需根据实际情况调整)。对于大量文本,可借助宏实现自动化:
Alt + F11 打开 VBA 编辑器。Sub HighlightDuplicates()
Dim para As Paragraph
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")
For Each para In ActiveDocument.Paragraphs
txt = Trim(para.Range.Text)
If txt <> "" And txt <> vbCr Then
If dict.exists(txt) Then
para.Range.HighlightColorIndex = wdYellow
Else
dict.Add txt, 1
End If
End If
Next para
End Sub
若文档复杂或需批量处理,可考虑导出为纯文本后使用专业去重工具,或借助支持重复检测的 Word 插件。