CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2001
    Posts
    401

    All MS Word/Office automation gurus out there!

    I am trying to print a range of pages using word but have not been able to do that, no matter what.
    I am not sure how to pass the paramaters for the page range option, so any suggestions are very much appreciated.

    I am calling the print out method like this


    Doc.PrintOut(covFalse, // Background.
    covOptional, // Append.
    covOptional, // Range.
    covOptional, // OutputFileName.
    covOptional, // // From.
    covOptional, // // To.
    covOptional, // Item.
    COleVariant((long)1), // Copies.
    covOptional, // Pages.
    covOptional, // PageType.
    covOptional, // PrintToFile.
    covOptional, // Collate.
    covOptional, // ActivePrinterMacGX.
    covOptional, // ManualDuplexPrint.
    covOptional, // PrintZoomColumn New with Word 2002
    covOptional, // PrintZoomRow ditto
    covOptional, // PrintZoomPaperWidth ditto
    covOptional);

    Well this print out fine, but when I try to pass the params for range, it fails, and if I try to use Pages param instead of from/to, then it still prints the whole document.

    I have tried passing the range as
    VARIANT vName;
    vName.vt = VT_BSTR;
    vName.bstrVal = SysAllocString(L"WdPrintOutRange.wdPrintFromTo");

    and the from/to as (long) 1/(long) 2, but it failed, so then Ipassed the pages options as below

    VARIANT vName2;
    vName2.vt = VT_BSTR;
    vName2.bstrVal = SysAllocString(L"1-2");

    But it instead prints the whole doc.

    Please help!

    Pauli

  2. #2
    Join Date
    Apr 2002
    Location
    Michigan, USA
    Posts
    869
    Quote Originally Posted by paulina_lui
    I am trying to print a range of pages using word but have not been able to do that, no matter what.
    I am not sure how to pass the paramaters for the page range option, so any suggestions are very much appreciated.

    I am calling the print out method like this


    Doc.PrintOut(covFalse, // Background.
    covOptional, // Append.
    covOptional, // Range.
    covOptional, // OutputFileName.
    covOptional, // // From.
    covOptional, // // To.
    covOptional, // Item.
    COleVariant((long)1), // Copies.
    covOptional, // Pages.
    covOptional, // PageType.
    covOptional, // PrintToFile.
    covOptional, // Collate.
    covOptional, // ActivePrinterMacGX.
    covOptional, // ManualDuplexPrint.
    covOptional, // PrintZoomColumn New with Word 2002
    covOptional, // PrintZoomRow ditto
    covOptional, // PrintZoomPaperWidth ditto
    covOptional);

    Well this print out fine, but when I try to pass the params for range, it fails, and if I try to use Pages param instead of from/to, then it still prints the whole document.

    I have tried passing the range as
    VARIANT vName;
    vName.vt = VT_BSTR;
    vName.bstrVal = SysAllocString(L"WdPrintOutRange.wdPrintFromTo");

    and the from/to as (long) 1/(long) 2, but it failed, so then Ipassed the pages options as below

    VARIANT vName2;
    vName2.vt = VT_BSTR;
    vName2.bstrVal = SysAllocString(L"1-2");

    But it instead prints the whole doc.

    Please help!

    Pauli
    see http://www.codeguru.com/forum/showpo...9&postcount=13
    Verere testudinem! (Fear the turtle)

    Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy. -Albert Einstein

    Robots are trying to steal my luggage.

  3. #3
    Join Date
    Nov 2001
    Posts
    401

    But there is nothing in that link

    I could really use some help here!

    Thanks!
    Pauli

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured