Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Richmond, Virginia, USA
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to count number of pages (2000 SP2)

    I am trying to write an If...Then statement that will do the following: If there is more than one page in this document, do <font color=red>this</font color=red>. If there is only one page in the document, do <font color=magenta>this other thing</font color=magenta>.

    Does anyone know how to have a macro count the number of pages in a document?

    Thanks,
    Becky

  2. #2
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Eugene, Oregon, USA
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to count number of pages (2000 SP2)

    Are you looking for something like...


    If ActiveDocument.Range.Information(wdActiveEndPageNu mber) > 1 then
    'do something
    Else
    'do something else
    End If

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Macro to count number of pages (2000 SP2)

    I have used the following

    Dim pagecount As Integer
    Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst
    pagecount = Selection.Information(wdNumberOfPagesInDocument)
    Regards
    John



Posting Permissions

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