select paragraphs in turn from document

I

ILMER57

I have a WORD 2007 document with many paragraphs. I want to select each
paragraph in turn and run a macro on just that paragraph then replace the
original paragraph with the one altered by the macro. Then move on to the
next paragrpah to repeat the proceedure. Any ideas?
 
C

Cindy M.

Hi Ilmer57,
I have a WORD 2007 document with many paragraphs. I want to select each
paragraph in turn and run a macro on just that paragraph then replace the
original paragraph with the one altered by the macro. Then move on to the
next paragrpah to repeat the proceedure.

I don't understand what the macro does to the paragraph, and why "the
original" needs to be replaced by the one the macro has worked on. What's the
macro doing that can't be done to the "original" paragraph directly?

If the macro could change the original paragraph, without needing to
delete/replace it, then a
For each para in doc.Paragraphs
'Macro actions here
Next

loop would work.

If you really need to replace the paragraphs, then you need to create a
collection or array, loop through the paragraphs as above and assign each
paragraph to the array or collection. Then you can loop through the array or
collection, perform the macro actions, delete the object and insert the
replacement.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
I

ILMER57

Cindy M. said:
Hi Ilmer57,


I don't understand what the macro does to the paragraph, and why "the
original" needs to be replaced by the one the macro has worked on. What's the
macro doing that can't be done to the "original" paragraph directly?

If the macro could change the original paragraph, without needing to
delete/replace it, then a
For each para in doc.Paragraphs
'Macro actions here
Next

loop would work.

If you really need to replace the paragraphs, then you need to create a
collection or array, loop through the paragraphs as above and assign each
paragraph to the array or collection. Then you can loop through the array or
collection, perform the macro actions, delete the object and insert the
replacement.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)

Hi Cindy,
Many thanks for your help. The code works fine and you are right, I do not
need to replace paragrpahs.
Thanks again
 

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