Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    88
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Sections Page Count (Word 2000)

    Is there any method of obtaining the total page count in a section through code? I know I can do it by inserting a field in the header or footer for SECTIONPAGES, but can't find a method by code directly.

    Thank you.

    Kyle

  2. #2
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Brussels, Brussel, Belgium
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sections Page Count (Word 2000)

    hi Kyle,

    the following seems to work for me.

    Function NumberOfPagesInSection _
    ( _
    ByRef CurrentSection As Section _
    ) As Long
    Dim StartSectionPage As Long
    Dim EndSectionPage As Long
    With CurrentSection
    EndSectionPage = _
    .Parent.Range _
    ( _
    .Range.End - 1, _
    .Range.End _
    ).Information(wdActiveEndPageNumber)
    StartSectionPage = _
    .Parent.Range _
    ( _
    .Range.Start, _
    .Range.Start _
    ).Information(wdActiveEndPageNumber)
    End With
    NumberOfPagesInSection = _
    EndSectionPage - StartSectionPage + 1
    End Function

    you can call the function for instance as follows:
    msgbox NumberOfPagesInSection(activedocument.Sections(3))

    greetings,

  3. #3
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    88
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Sections Page Count (Word 2000)

    Hi Pieter.

    Thanks so much. It worked but I did have to remove the increase of 1 to the subtraction of the starting and ending page number of the page range. I'm not sure why because it does make sense that it should be increased by one. I could not get an accurate page count with the +1.

    Kyle

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •