Categories
木有技术

删除Word中的水平线(分割线)

在Word种有个很SB的东西叫做水平线/分割线,就是按连续3个-或者=或者~之类的字符后回车会生成的水平线。具体效果见“Word中简单快速插入各种分隔线及删除分割线的方法”
问题来了,当你想要删去他们的时候,有时候按del键完全不起作用。
这个时候,有个办法,就是用VBA代码(对,那个古老的VB),具体如下:

  1. 按下Alt+F11键打开VBA编辑器;
  2. 双击下图中红圈部分(ThisDocument)vba_editor_word
  3. 在打开的代码编辑器中,粘贴这个代码
    Sub removehline()
        Dim ils As Paragraph
        For Each ils In ActiveDocument.Paragraphs
            ils.Borders(wdBorderBottom).LineStyle =wdLineStyleNone
        Next ils
    End Sub

     

  4. 点击绿色的小箭头,或按F5键运行代码。搞定!
  5. 记得运行完后把VBA代码删了,不然保存的时候会提示宏啊什么的…突然想到Word97时候的宏病毒~

 
参考资料:How to remove all horizontal lines from Word document?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.