Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    859
    Thanks
    0
    Thanked 10 Times in 9 Posts

    Using ActiveDocument.PrintOut

    I'm using ActiveDocument.Printout in Word 2010. My code determines which pages in the document have revisions, and I print only those pages to the Adobe PDF printer. This functions just as I want it to, but the Pages option seems to have a limit. I'm guessing that it's the length of the variant: p1s1,p5s1,p3s2 etc. to indicate the pages/section to be printed. I am able to print about 30 pages, but if I eliminate the section number (if it's a one-section document), I can nearly double the number of pages by using 1,5,7,12, etc.. Therefore, my guess is that the variant for Pages has a limit of about 256 characters. I can't find any documentation the refers directly to the variant length. Does any know, or know where to find, what this limit actually is? Thanks.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,158
    Thanks
    200
    Thanked 781 Times in 715 Posts
    RIchard,

    According to: O'Reilly's "VB & VBA in a Nutshell" by Paul Lomax:
    Variant (String) 22 bytes + length of string, Range same as variable length string.

    String (variable length) Range 0-2 Billion characters! (seems like a little more than 256 chars!)
    "VBA for Dummies" by Steve Cummings agrees with the above.

    According to: Que's "Special Edition Using Excel Visual Basic" by Jeff Walsh:
    String Range 0-65536
    Variant Range any number up to double or any string.

    According to OZGrid.
    Variant data type
    Variant data type A special data type that can contain numeric, string, or date data as well as the special values Empty and Null. The Variant data type has a numeric storage size of 16 bytes and can contain data up to the range of a Decimal, or a character storage size of 22 bytes (plus string length), and can store any character text. The VarType function defines how the data in a Variant is treated. All variables become Variant data types if not explicitly declared as some other data type.
    String data type
    A data type consisting of a sequence of contiguous characters that represent the characters themselves rather than their numeric values. A String can include letters, numbers, spaces, and punctuation. The String data type can store fixed-length strings ranging in length from 0 to approximately 63K characters and dynamic strings ranging in length from 0 to approximately 2 billion characters. The dollar sign ($) type-declaration character represents a String in Visual Basic.

    HTH
    Last edited by RetiredGeek; 2014-01-16 at 20:00.
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    859
    Thanks
    0
    Thanked 10 Times in 9 Posts
    Thanks, but I'm asking about the maximum length of the Pages parameter of the Printout method of ActiveDocument. In the code below, ***** indicates where this variant would appear. The PrintOut method fails (without an error) if the variant is too long, and I'm wondering if there's a documented maximum length for the Pages parameter.

    Code:
    ActivePrinter = "Adobe PDF"
        
        Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
            wdPrintDocumentWithMarkup, Copies:=1, Pages:=******, _
            PageType:=wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:= _
            False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
            PrintZoomPaperHeight:=0

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,158
    Thanks
    200
    Thanked 781 Times in 715 Posts
    Richard,

    The MSDN documentation (all I think you're going to find) only specifies Variant so I would assume there is no additional documented limit. Of course YMDV!
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


Posting Permissions

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