用于删除 Word 文档中所有重复文本实例的宏
我正在寻找一种简单的方法来删除 Word 2007 文档中的重复文本。如果查找/替换命令有一些快捷方式,我没有看到它。否则,有人可以建议我如何编写一个如下所示的宏:
1-选择一个文本块(可以是多个段落,有项目符号点等)。
2- 运行宏或执行命令。
3- 宏或命令删除所选文本块的所有实例。
这里有什么见解吗?
I'm looking for a simple way to delete repeated text in a Word 2007 document. If there are some shortcuts with the Find/Replace commands, I'm not seeing it. Otherwise, can someone recommend how I might write a macro that works like the following:
1- Select a block of text (could be mulitple paragraphs, have bullet points, etc).
2- Run the macro or do the command.
3- The macro or command deletes all instances of the selected text block.
Any insight here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Selection.Text 返回当前选择的文本。
原则上,替换命令的语法是:
替换为空字符串,从而删除要查找的文本的每个实例。
但是:您当然必须决定如何处理选定文本的格式,也许必须首先分析您选定的块,因为替换可能不适用于 Selection.Text 忽略的控制字符...这这只是开始,您需要指定您想要什么,然后再次询问您自己或我们。同时录制宏和vba参考这个词是你的朋友。
Selection.Text returns the current selection's text.
In principle, the syntax for your Replace command is:
You replace by an empty string, thus delete every instance of the text to find.
But: You have to decide of course how to handle the formatting of the selected text, maybe have to analyze your selected block first because replacing might not work with control chars neglected by Selection.Text ... This is just the start, you need to specify what you want and then ask again, yourself or us. Meanwhile Record macro and the word vba reference are your friends.
对于字母数字文本(没有换行符),您可以使用查找/替换,但是一旦您进入项目符号、新段落等领域,它将不再进行精确匹配。如果您经常需要这样做,我建议使用像 LaTeX 这样的程序来编写文档。 LaTeX 允许您对大文本块进行这种精确匹配。如果您使用的是 Windows 计算机,proTeXt 就是一个很棒的 LaTeX 软件包,可以在 http://www 找到.tug.org/protext/
For alpha number text (with out newlines), you can use Find/Replace however as soon as you get in the realm of bullets, new paragraphs, etc. it will no longer do exact matching. If you often need to do that, I would suggest using a program like LaTeX to write your documents. LaTeX would allow you do this style of exact matching of large blocks of text. If you're on a Windows machine, a great LaTeX package would be proTeXt which can be found at http://www.tug.org/protext/
我遇到了完全相同的问题,巨大的邮件列表,我只需要电子邮件。我通过复制Excel中的文本,逐句(或项目符号)过滤我想要删除的段落并删除所有行来解决这个问题。我的有270多页,效果很好(只要文本不是太长,它比逐句替换单词要快得多。)或者如果是一个选项,只需使用文本过滤器进行过滤 - 开始使用 "to:" ,那么您将在 10 秒内完成。希望有帮助。
I had exactly the same problem, huge mailing list and I just needed the emails. I solved it by copying the text in excel, filtering sentence by sentence (or bullets) the paragraph i wanted to remove and deleting all rows. Mine was more than 270 pages, worked just fine (as long as the text is not too long, it was a lot faster than replaceing sentence by sentence in word.) Or if it is an option, just filter with a text filter - begins with "to:" , then you are done in 10 secs. Hope it helps.
只需按 Ctrl+H 选择并替换文本,输入要删除的文本,然后按全部替换,将替换字段保留为空白
Just Press Ctrl+H to select and replace text, Type the text you want to remove and Press Replace All leaving replace with field BLANK