简体   繁体   English

MS Word,如何在整个文档中自动更改整个段落的格式?

[英]MS Word, how to change formatting of entire paragraphs automatically in whole document?

I have a 20-page word document punctuated with descriptive notes throughout, like this:我有一个 20 页的 word 文档,其中标有描述性注释,如下所示:

3 Input Data Requirements 3 输入数据要求
Some requirement text.一些需求文本。
NOTE: This is a descriptive note about the requirement, which is the paragraph that I would like to use find-and-replace or a VBA script to select automatically and change the formatting to italicized.注意:这是关于要求的描述性说明,这是我想使用查找和替换或 VBA 脚本自动选择并将格式更改为斜体的段落。 The notes invariably end in a carriage-return: ¶.注释总是以回车符结尾:¶。

If it was just a text document, not MS-Word, I would just use a regex in a code editor like sublime to wrap it with <I> ... </I> or something along those lines.如果它只是一个文本文档,而不是 MS-Word,我会在代码编辑器(如 sublime)中使用正则表达式将它包裹在<I> ... </I>或类似的东西中。

Preferably, is there a way to do this in Word's "advanced" find-and-replace feature?最好,有没有办法在 Word 的“高级”查找和替换功能中做到这一点? Or if not, what's the best way to do it in VBA?或者,如果没有,在 VBA 中最好的方法是什么? I've tried using a search string like this in find-and-replace: NOTE: *[a-z0-9,. AZ)(-]{1,255}^l我试过在查找和替换中使用这样的搜索字符串: NOTE: *[a-z0-9,. AZ)(-]{1,255}^l NOTE: *[a-z0-9,. AZ)(-]{1,255}^l but the line-break part doesn't seem to work, and the 255 char max isn't enough for many of the paragraphs. NOTE: *[a-z0-9,. AZ)(-]{1,255}^l但换行部分似乎不起作用,对于许多段落来说,最大 255 个字符是不够的。

EDIT: Another slightly important detail: The doc is automatically generated from another piece of software as a .RTF, which I promptly converted to .docx.编辑:另一个稍微重要的细节:该文档是从另一个软件自动生成的 .RTF,我立即将其转换为 .docx。

Attempt #2: Use Notepad++ to find and replace using regex.尝试 #2:使用 Notepad++ 查找和使用正则表达式替换。 Remove quotes.删除引号。

Find: "( NOTE: .*?)\\r"查找:“(注意:.*?)\\r”

Replace with: " \\i \\1 \\i0 \\r "替换为:“ \\i \\1 \\i0 \\r ”

//OLD //旧

Sure is.当然是。 No VBA or fancy tricks needed.不需要 VBA 或花哨的技巧。

  • CTRL + H to bring up the replace dialog. CTRL + H 调出替换对话框。
  • Click "More".点击“更多”。
  • Select "Font" in the drop down menu called "Format".在名为“格式”的下拉菜单中选择“字体”。
  • Click italics.单击斜体。
  • Enter find and replace text as the same thing.输入查找和替换文本作为相同的内容。 Make sure you set this up right so that you don't accidentally replace substrings (eg goal to replace all " test " with " nice ", testing -> niceing).确保设置正确,以免意外替换子字符串(例如,目标是将所有“测试”替换为“nice”,testing -> niceing)。

Should work.应该工作。 If you need to alter entire paragraphs, consistently, then you probably should have used the styles on those paragraphs to begin with.如果您需要一致地更改整个段落,那么您可能应该在开始时使用这些段落的样式。 That way, you can change all of them at once by updating the style itself.这样,您可以通过更新样式本身来一次性更改所有样式。

You can use Advance Find, yes.您可以使用高级查找,是的。 Find Next and then Replace makes the selection Italic.查找下一个,然后替换使选择斜体。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM