I need to black out all the lines in a long document that begin with special characters and are followed by specific words. For example, if a line begins with *boot or >jump like in:




Then I need to black out all text following and including the *boot and >jump, wherever it appears, until the end of the line i.e., until I hit a paragraph symbol if symbols are showing. (All lines begin on the left). BUT, if, for example, I had *run at the beginning of a line, or *boot or >jump in the middle, I wouldn't want to delete it.

The find and replace feature won't work, insofar as I know how to use it, if you want to use wildcards AND search for text that includes special characters like * and >.

I know I should be able to write a macro for this, but I don't know enough VBA. Anyone know what to do? I'm working in Windows 10, Office 365.

  • Perhaps you need to escape the * and > characters. Try entering them as \* and \>
    – RJFalconer
    Commented Dec 9, 2016 at 10:51

2 Answers 2


Sounds like you could accomplish at least the search part with a RegEx search.

See this SO answer for more details: https://stackoverflow.com/questions/24308538/find-and-replace-with-regex-in-microsoft-word-2013

  • And then in the regular expression, I assume one can "escape" the asterisk with a slash, \*, to avoid it from being interpreted as "zero or more". So, I assume something like ^\*boot.*$ would work, where ^ is the start of the line, and $ the end, and .* is just zero or more characters.
    – Arjan
    Commented Dec 9, 2016 at 10:52

1) Do a Find & replace with wildcards disabled, replacing all instances of * and any other wildcards with some other character which isn't used anywhere else. Eg replace * with $, ? with £ etc

2) Once these have been replaced it will be easy to do a wildcard search for everything from the "$boot" text until the line break. Do whatever formatting you want to do.

3) Do a new find & replace to replace all $ back to * and £ to ? (this is why in step 1 I said to use a symbol which isn't used anywhere)

  • This still needs one to be sure to only match £boot at the beginning of a line. I've no idea if Word Find & Replace supports that, but I guess it does?
    – Arjan
    Commented Dec 9, 2016 at 10:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .