Word macro for printing only paragraphs with specified words
Posted on 2014-01-14
I'm using Word in Office 2014 under Win 8.1 to do research involving very long documents (hundreds of pages) where I need to focus my searches on paragraphs that contain at least one (of up to 20) words.
I need suggestions for macros to help me, as follows:
(a) I would enter the (up to 20 words) into the macro. Rather than being prompted, I'd enter them directly into the macro for each separate run of the macro.
(b) If it would be easier, I could insert into the macro code the total number of pages in the document to be researched for each run of the macro.
The words to researched must be case sensitive and both partial and whole in the same search -- not necessarily whole words (for example, I want to include suffices including, but not limited to, ...ing, ...ed, ...'s, etc.)
(a) The goal is produce a 2nd document for printing only the paragraphs where one or more of the target words occur. Each of the target words in both docs should be highlighted to the then current highlight color (and left that way upon macro completion).
(b) It seems that the macro MUST (you decide) run two passes where the first pass highlights the (up to 20) target words and, for the second pass, prints each paragraph that contains at least one targeted word.
(c) Target paragraphs copied to the 2nd doc. should be inserted in their original sequence, without forced page breaks, but with a couple of blank lines in between (with all targeted words highlighted). For each paragraph copied into the 2nd doc, I really need to know what page it came from in the original doc. Perhaps the easiest way to capture this page info. might be to grab it from the location of the first word in each paragraph before the paragraph is copied to the 2nd doc. That page number should be printed in the line before the paragraphs.
(d) Printing must not be automatic, but under my manual control, after the macro has completed and I am able to inspect the results.
Six years ago I could have done this fairly quickly in Word 2003 under XP, but I've been away too long, there have been multiple changes to MS Word and the OS since that time.
Appreciate the help and even partial code suggestions from one or more experts.