跳到主要内容

如何在Word文档中查找并突出显示重复的段落?

作者:晓阳 最后修改时间:2018-09-19

假设您有一个大的Word文档,该文档可能有数百页,现在,您要检查是否存在重复的段落,然后突出显示使其突出显示,以便可以处理重复的句子。 您如何在Word文档中快速轻松地查找并突出显示重复的段落?

使用VBA代码查找并突出显示Word文档中的重复段落


使用VBA代码查找并突出显示Word文档中的重复段落

要查找并突出显示Word文档中的重复段落,请按照以下VBA代码进行操作:

1。 按住 ALT + F11 键打开 Microsoft Visual Basic应用程序 窗口。

2。 然后,单击 插页 > 模块,将以下代码复制并粘贴到打开的空白模块中:

VBA代码:查找并突出显示Word文档中的重复段落:

Sub highlightdup()
    Dim I, J As Long
    Dim xRngFind, xRng As Range
    Dim xStrFind, xStr As String
    Options.DefaultHighlightColorIndex = wdYellow
    Application.ScreenUpdating = False
    With ActiveDocument
        For I = 1 To .Paragraphs.Count - 1
            Set xRngFind = .Paragraphs(I).Range
            If xRngFind.HighlightColorIndex <> wdYellow Then
                For J = I + 1 To .Paragraphs.Count
                    Set xRng = .Paragraphs(J).Range
                    If xRngFind.Text = xRng.Text Then
                        xRngFind.HighlightColorIndex = wdBrightGreen
                        xRng.HighlightColorIndex = wdYellow
                    End If
                Next
            End If
        Next
    End With
End Sub

3。 然后按 F5 运行此代码的关键,所有重复的句子都立即突出显示,显示的第一个重复段落用绿色突出显示,其他重复用黄色突出显示,请参见屏幕截图:

doc高亮dup句子1

最佳办公生产力工具

Kutools for Word - 通过 Over 提升您的文字体验 100 显着特点!

🤖 Kutools 人工智能助手:用人工智能改变你的写作 - 生成内容  /  重写文本  /  总结文件  /  快速获得答案,全部在Word中

📘 文档掌握: 分页  /  合并文件  /  以各种格式导出选择(PDF/TXT/DOC/HTML...)  /  批量转换为PDF  /  将页面导出为图像  /  一次打印多个文件...

内容编辑: 批量查找和替换 跨多个文件  /  调整所有图片的大小  /  转置表行和列  /  将表格转换为文字...

🧹 轻松清洁: 移开 多余的空间  /  分节符  /  所有标题  /  文本框  /  超链接  / 如需更多拆卸工具,请前往 删除组...

创意插入: 插 千位分隔符  /  复选框  /  单选按钮  /  扫码支付  /  条码  /  对角线表  /  公式标题  /  图片说明  /  表标题  /  多张图片  / 发现更多 插入组...

🔍 精准选择:精确定位 特定页面  /    /  形状  /  标题段落  / 增强导航功能 更多 选择功能...

星级增强: 导航到任何位置  /  自动插入重复文本  /  在文档窗口之间切换  /  11 转换工具...

👉 想要尝试这些功能吗?立即下载 Kutools for Word! 🚀
 
Comments (15)
Rated 4.5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Can you help me it is not working can you helphttps://1drv.ms/w/s!Aja8bo-tfhqb-FVWcGUyvYPv07cX?e=lgJ4i1
This comment was minimized by the moderator on the site
Hi, mình chạy đoạn code trên nhưng không thấy ra kết quả giống bài viết, mình dùng word 2019, Ad support giúp mình nhé 
This comment was minimized by the moderator on the site
Hi, can anyone please suggest me to prepare a macro in ms word for finding error in paragraph.
Like:- "and or" "that that" "of the of the" "Sentence end without dot (.)" "New Sentence start with initial caps without ending the sending".
This comment was minimized by the moderator on the site
Thanks so much.A very valuable article, helped me with my duplicate copies and paste paragraphs!You are awesome.
This comment was minimized by the moderator on the site
Tried this for my book in MS Word. First, it would not work because I had bullet points. I removed them and then it only found 2 instances "blank page" and "table of contents". I purposely have several sentences repeated, and this macro did not find them. Thank you for trying, but I would say this doesn't work.
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations