Sections: Index and Count

R

Roderick O'Regan

Can anyone help with the following, please?

I have a document with a large number of sections. My cursor will be
in the footer of a randomly selected section from which I need to step
forward through each one checking a sequence until the last section is
reached.

In the normal course of events I might use an "On error..." statement
which would occur when arriving at the last section and my code asks
for another one. I would exit from the routine at this point as the
error would be trapped.

However, in this instance, when I arrive at the last section whilst
still in the footers and update my sequence the cursor flips back to
the previous section. The code continues to ask for the next section
and therefore a loop is generated.

I know how to determine the number of sections in a document and also
know how to go to the last one as well as stepping through each
section.

But how can I find out when I've arrived at the last section after
each step through? Is there a way of comparing the index of the
section the cursor is located against the total number of sections?

Regards

Roderick O'Regan
 
H

Helmut Weber

Hi Roderick,
apart from possible complications,
if ActiveDocument.Sections.Count =
Selection.Information(wdActiveEndSectionNumber) then
I'd say, you have arrived at the last section.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

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