Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Word Pages and Sections

Status
Not open for further replies.
Apr 10, 2000
155
US
I want to loop through a document to find out what pages are in what sections. The output after the macro runs should look like:

Pages 1-3, Section 1
Pages 4-10, Section 2
Pages 11-15, Section 3

Thanks for any help you can give.
 
Hi,

It depends on the printer driver on the computer. This is like asking how many days are there in a month.

Read this discussion in thread68-1521232.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
But if I open a document and move from page to page Word knows what page it is on as well as what section it is in doesn't it? I can bbuild the string for the output but cannot seem to find the property for currentpage and currentsection while I have the macro move from page to page. Sorry if I am being dense but I would think this should be easy.
 
Found what I needed.

Selection.Information(wdActiveEndPageNumber) & " " & Selection.Information(wdActiveEndSectionNumber)

Thanks.
 
A Section is a Section, no matter what computer

A Page is not a page from computer/printer driver to computer/printer driver.

Please tell me what you are trying to do. And don't tell me "what pages are in what sections!" What is your purpose?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
The following code is giving the user what they want for now. I do not know why they want this but they do.

Dim strPageSection As String
Selection.HomeKey Unit:=wdStory
strPageSection = "Page 1 - Section 1" & vbCrLf

Do Until Selection.Information(wdActiveEndPageNumber) = Selection.Information(wdNumberOfPagesInDocument)
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
strPageSection = strPageSection & "Page " & Selection.Information(wdActiveEndPageNumber) & " - Section " & Selection.Information(wdActiveEndSectionNumber) & vbCrLf
Loop

Documents.Add DocumentType:=wdNewBlankDocument
Selection.TypeText Text:=strPageSection

 


"The following code is giving the user what they want for now"

Wonderful!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Except the code does NOT return:

"I want to loop through a document to find out what pages are in what sections. The output after the macro runs should look like:

Pages 1-3, Section 1
Pages 4-10, Section 2
Pages 11-15, Section 3

The code returns:

Page 1 - Section 1
Page 2 - Section 1
Page 3 - Section 1
Page 4 - Section 2
Page 5 - Section 2
Page 6 - Section 2
Page 7 - Section 2
Page 8 - Section 2
Page 9 - Section 2
Page 10 - Section 2
Page 11 - Section 3
Page 12 - Section 3
Page 13 - Section 3
Page 14 - Section 3
Page 15 - Section 3

But as Skip mentions, if it is giving what they want....wonderful.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top