MS Word, how to change the formatting of whole paragraphs automatically in a complete document?

advertisements

I have a 20-page word document punctuated with descriptive notes throughout, like this:

3     Input Data Requirements
    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. 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.

Preferably, is there a way to do this in Word's "advanced" find-and-replace feature? Or if not, what's the best way to do it in VBA? I've tried using a search string like this in find-and-replace: NOTE: *[a-z0-9,. A-Z)(-]{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.

EDIT: Another slightly important detail: The doc is automatically generated from another piece of software as a .RTF, which I promptly converted to .docx.


Attempt #2: Use Notepad++ to find and replace using regex. Remove quotes.

Find: "( NOTE: .*?)\r"

Replace with: " \i \1 \i0 \r "

//OLD

Sure is. No VBA or fancy tricks needed.

  • CTRL + H to bring up the replace dialog.
  • 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 (e.g. goal to replace all " test " with " 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.