Code to access different section breaks
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Code to access different section breaks
I have a document with mutable section breaks, is there any type of code that I can use to navigate quickly to each section. This document has about 20 section page breaks with about a total of 65 pages so it can take a minute to scroll down the page
-
- Administrator
- Posts: 78524
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Code to access different section breaks
If you want to go to the next section:
Selection.GoTo What:=wdGoToSection, Which:=wdGoToNext
or to the previous section:
Selection.GoTo What:=wdGoToSection, Which:=wdGoToPrevious
To go to a specific section, e.g. the 3rd one in the document:
Selection.GoTo What:=wdGoToSection, Which:=wdGoToAbsolute, Count:=3
Selection.GoTo What:=wdGoToSection, Which:=wdGoToNext
or to the previous section:
Selection.GoTo What:=wdGoToSection, Which:=wdGoToPrevious
To go to a specific section, e.g. the 3rd one in the document:
Selection.GoTo What:=wdGoToSection, Which:=wdGoToAbsolute, Count:=3
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Code to access different section breaks
Thank you Hans
This will help speed up the process.
By looking at this code I would of never figured this one out
This will help speed up the process.
By looking at this code I would of never figured this one out
-
- Administrator
- Posts: 12612
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Code to access different section breaks
I assume you are aware that you can navigate to a section from the user interface without using any code at all.
Control-G to get the GoTo dialog box
Select section in the list on the left
Enter the required section number in the text box (or +1 to move forward one section etc.)
OK
Control-G to get the GoTo dialog box
Select section in the list on the left
Enter the required section number in the text box (or +1 to move forward one section etc.)
OK
StuartR
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Code to access different section breaks
Thank you StuartR
For me it works great, for other users, numbers referring to sections maybe confusing. So I decided to use the code that Hans has provided and label each button with a reference name
Again many thanks
For me it works great, for other users, numbers referring to sections maybe confusing. So I decided to use the code that Hans has provided and label each button with a reference name
Again many thanks