Thread: [Solved] Loop Until End of Document
View Single Post
 
Old 02-21-2021, 01:01 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Stephen Ray View Post
I wrote this for myself to process a bulk of documents, assembled into one document, that were all similar except for a many variables like names and states; and where each document had to be re-arranged according to a certain formula. I needed some way to tell it to stop, end of document.
There are many code examples in this forum showing how to loop through paragraphs (if necessary) correctly. See, for example:
https://www.msofficeforums.com/123696-post2.html
https://www.msofficeforums.com/89357-post2.html
https://www.msofficeforums.com/word-...ge-header.html
https://www.msofficeforums.com/word-...nt-length.html
https://www.msofficeforums.com/139350-post2.html
https://www.msofficeforums.com/word-...ngle-line.html
None of these needs to select anything to do the required work and none needs an arbitrary counter to exit when done.

Content re-arrangement can often be done without the burden of looping through all paragraphs, though, via Find/Replace.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote