The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Help with a Word Macro...


I am hoping someone can help asnwer this question:

Let's say I have a word "XYZ" scattered throughout my Word document. That Word document contains many heading levels, like:


How do I write a macro that can remove "XYZ" only if it is in the 4th
heading level (e.g.,,, etc.)?

Also, how do I make it so the macro can also search for text blocks that span multiple lines, like, for example,:

•    B
•    D

I want to be able to find and replace all text blocks that have exactly the above format and everything, including the bullets.

Word Macro Programming
Tuesday, May 06, 2008
For the first one:

You can use the Styles sidebar to select all paragraphs having the Heading 4 style —with the style contextual menu option 'Select all N instance(s)—, and then do a search and replace over the current selection (there is no option on the replace dialog for searching only the current selection, but by default word will only replace text on the selected paragraphs, and then will ask if you want to search the rest of the document.

If you have to do this on several documents, I think you can record this as an interactive macro and save it in the template. Then replay the macro on every document.

Regarding your second question, I really don't understand what are you trying to accomplish. What exactly are A, B, C and D?
not a guru Send private email
Friday, May 09, 2008
I mean, you need to replace all the occurences of the same paragraphs with the same exact formatting and text? or just paragraphs with the same formatting?
not a guru Send private email
Friday, May 09, 2008

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz