|
#1
|
|||
|
|||
Greg Maxey,
Yes, indeed, you may very well ask, "What is the point of that message box that tells you how many lines....." I failed to mention, the msg box should be taken out, for actual use. But it sure was handy for developing and testing. The point is not counting the lines, nor seeing the count. The point is: Stopping the loop when the insertion point arrives on the last line of the document. This Test returns = True - Only When the last Paragraph Mark in the document is highlighted. 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. |
#2
|
|||
|
|||
macropod,
Thank you for your reply. I believe my reply to Greg Maxey will relieve some of your objections. And I must confess to ignorance about your other objections. But I am going to hang tough about the good utility of the Macro I wrote. It serves me very well. And if I can help the next guy, then I am a happy man. |
#3
|
||||
|
||||
Quote:
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] |
#4
|
|||
|
|||
Macropod,
Thank you for your reply. The purpose of my Macro is not to loop through paragraphs correctly. The arbitrary counter is not needed to test: Selection.Range.End = ActiveDocument.Range.End However, I like the good counter for testing, development and demonstration purposes. Content re-arrangement of sets of data does not lend itself to Find/Replace because each set has different variables. My Macro solves the problem of working through the last set and stopping the loop after the last set. It does this very well. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to loop once through document | PrincessApril | Word VBA | 4 | 04-12-2020 06:06 AM |
Loop thru document and create bookmarks | jeffreybrown | Word VBA | 3 | 09-22-2018 06:04 AM |
Loop true all opned word document | elbartje | Word VBA | 1 | 06-12-2017 05:27 PM |
VB for Word - Need macro to loop each line in a document | NDeane | Word VBA | 5 | 12-22-2015 08:12 PM |
Loop through files and Copy Table Row and Paste into Different Document | spiderman1369 | Word VBA | 2 | 10-15-2014 08:30 AM |