Macro loop until end of file

Joined
Mar 3, 2017
Messages
2
Reaction score
0
I have a document with a variable number of sections and subsections. What I need to do is to check that the main sections don't start on even pages. If I'd had some specific text to look for, I'd use the .Find function, but that is not the case in my situation. I'd like to use a while loop like while not endOfFile to loop through all sections, but I don't know how to find the end of a file. Can someone please help me find out what the end of file code is so I can search for it?

Chris
 
Joined
Mar 3, 2017
Messages
2
Reaction score
0
Actually, after testing some code, I have found that what I really need to check is whether I'm on the last section instead of the end of the file because when I try to move to the next section from the last one, it doesn't move anywhere. So, how can I determine if the loop has brought me to the last section.
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
578
Reaction score
50
I have a document with a variable number of sections and subsections. What I need to do is to check that the main sections don't start on even pages.
It would be helpful if you used Word terminology; without it your requirements are quite unclear. Word does not have subsections; it has various kinds of Section breaks. Are you using any of these? If so, are they used for what you're calling: sections; subsections; or sections and subsections alike? If not, how would a macro recognise what you refer to as a section or subsection (e.g. different Heading Styles used for sections and subsections)?
 

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