Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2004
    Location
    New York, New York, USA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    number of pages in a document (Word 2002 sp3)

    I have written a macro which creates a number of documents (6), one after the other, and sends them to a printer. My difficulty is the fact that The documents all have to be printed on different types of paper, and the length of the documents vary. I would like to create a message box that says "Put X pages of Y type of paper in the printer" after each document is prepared. The macro closes each document after sending it to the printer, so that after the macro is done I am not left with 6 open documents to close manually. Obviously, I could leave them open, check how many pages of each, and then have a separate Close all macro run (I believe I got that from Woody), but that's not as much fun as figuring out this problem.
    Thanks
    Arlene <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

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

    Re: number of pages in a document (Word 2002 sp3)

    You can use

    ActiveDocument.Content.Information(wdNumberOfPages InDocument)

    or if you use a variable doc of type Document:

    doc.Content.Information(wdNumberOfPagesInDocument)

    to retrieve the number of pages in the document. So you could use something like this:

    Dim lngNumPages As Long
    Dim strPaperType As String
    ...
    lngNumPages = ActiveDocument.Content.Information(wdNumberOfPages InDocument)
    strPaperType = "Legal"
    MsgBox "Please put " & lngNumPages & " of " & strPaperType & " type paper in the printer", vbInformation
    ...

  3. #3
    New Lounger
    Join Date
    Feb 2004
    Location
    New York, New York, USA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: number of pages in a document (Word 2002 sp3)

    Thank you so much, Hans! This worked like a charm...I've been wracking my brains on it for months, every time I found a spare few minutes, which doesn't happen too often.
    Arlene

Posting Permissions

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