Looping Macro

M

Me

I'm curious as to whether a macro can be created to be used in Word 2003. I
would need the macro to do the following:

1. Begin the macro on the first page of the document.
2. Find the first occurrence of )@(
3. Hide all text until it finds the first occurrence of )^(
4. It should loop through the entire document hiding all text between these
two character fields. The text between the two characters will be of varying
length.

This would be the data before running the macro:

)@( Now is the time for all good men to come to the aid of their country.
)^( Wednesday, March 7, 2007. )@( Now is the time for all good men to come
to the aid of their country. )^( )@( Now is the time for all good men to
come to the aid of their country. )^( Outage Expectations. )@( Now is the
time for all good men to come to the aid of their country. )^(

This should be the result after running the macro:

Wednesday, March 7, 2007. Outage Expectations.

Is this possible?

FYI -- I don't have any knowledge of VB, and my macro knowledge is suspect.

Thank you.
 
J

Jay Freedman

Hi, Me,

You don't need a macro -- although you can make one if you really want to.
The whole thing can be done in the ordinary Replace dialog, using wildcards.
For a tutorial on the subject, see
http://www.gmayor.com/replace_using_wildcards.htm.

In the Replace dialog, click the More button and check the "Use wildcards"
box. In the Find What box, enter this (use copy/paste unless you're very
confident of your typing):

\)\@\(*\)^094\(

In the Replace With box, enter the code

\1

Then click the Format button, choose Font, and check the Hidden box; then
OK.

Finally, click the Replace All button. Done.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top