Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Counting Pages through VBA (Windows XP/Office 2003)

    Morning

    Just a quick query .... I have some code that counts the pages within a document and have noticed that the count works for Print Layout View but trips in Normal View. The code I have is:

    lngCount = docDocument.ActiveWindow.Panes(1).Pages.count

    Is there a different way to count pages, I've looked at Help and it seems to indicate that you can only count in Print Layout View.

    Many thanks
    Jack

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Counting Pages through VBA (Windows XP/Office 2003)

    Is Pages new in Word 2003 VBA? It doesn't exist in Word 2002. You can use this:

    docDocument.Content.Information(wdNumberOfPagesInD ocument)

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Counting Pages through VBA (Windows XP/Office 2003)

    <code>ActiveDocument.Content.Information(wdActiveE ndPageNumber)</code>

    Seems to work.

    StuartR

    I see <!profile=HansV>HansV<!/profile> beat me to it again <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Counting Pages through VBA (Windows XP/Office

    I don't know whether it's because I tried the third one last, but the first two definitely repaginate, while the third seemed not to. So it might be faster, but might not be as up-to-date in Normal view.

    ?activedocument.Content.ComputeStatistics(wdStatis ticPages)
    43
    ?activedocument.Content.Information(wdNumberOfPage sInDocument)
    43
    ?activedocument.Content.Information(wdActiveEndPag eNumber)
    43

Posting Permissions

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