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

    MS Word PrintOut function- Please help, have chekced MSDN/Google no help

    Well I am able to print using the print out function but when I try to pass parameters like which pages to print etc, I am not able to do that.

    myDoc.PrintOut(covFalse, // Background.
    covOptional, // Append.
    &vName,//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)

    So this code works perfectly and print the doc, but what I want to od is print only a number thats entered by the user like pages 2 to 8 or or like 2,4-5 , now from help it seems its possible to do that but all samples are in vb and I dont know know how to do all that in c++, as have tried all combinations and it wonr work, and starts to fail altogethere.

    I have tried like
    VARIANT vName;
    vName.vt = VT_BSTR;
    vName.bstrVal = SysAllocString(L"WdPrintOutRange.wdPrintFromTo");
    myDoc.PrintOut(covFalse, // Background.
    covOptional, // Append.
    &vName,//covOptional, // Range.
    covOptional, // OutputFileName.
    COleVariant((long)1), //covOptional, // // From.
    COleVariant((long)2), //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)

    it fails, and nothing is printed even.

    I also have to pass options like the paper size(letter size or a4, but how can I do that).

    Please help!

    Pauli

  2. #2
    Join Date
    Apr 2002
    Location
    Michigan, USA
    Posts
    869
    Have you tried specifying the pages in the Pages parameter instead of the From To parameters?
    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

    Well

    Frankly I dont know whats the best way to do that I did try passing the values as COleVariant((_T("2-4")), but it prints all the pages instead.

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