CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    Join Date
    Nov 2001
    Posts
    401

    Thanks a lot Tom

    I could not get to the whole thread from the link you had in the your reply,

    Anyways I tried that but still it prints the whole **** document.

    I am using
    myDoc.PrintOut(covTrue, // Background.
    covFalse,//covOptional, // Append.
    COleVariant((long)5),//covOptional, // Range.
    covOptional, // OutputFileName.
    covOptional, // // From.
    covOptional, // // To.
    covOptional, // Item.
    COleVariant(numCps), // Copies.
    COleVariant(_T("2,3")),//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);

    I have to use COleVariant(_T("2,3")) as COleVariant("2,3") gave the error:: error C2440: 'type cast' : cannot convert from 'char [4]' to 'class COleVariant'

    I am opening the document like this word:ocuments myDocs = myWord.GetDocuments();
    myDoc= myDocs.Open(COleVariant(szFileName),
    covFalse,covTrue,covFalse,covOptional,covOptional,covFalse,covOptional,
    covOptional,covOptional,covOptional,covTrue);

    Thanks for your time!
    Pauli

  2. #17
    Join Date
    Apr 2002
    Location
    Michigan, USA
    Posts
    869
    I tried this on my home machine with office XP and tried out your printout command.
    It printed out pages 2 and 3 alone after I changed the 5 to a 4 as below.
    I always rewrite the Open method so that it has only one argument which is why my open looks different.


    _Application objWord;
    COleVariant covTrue((short)TRUE),
    covFalse((short)FALSE),
    covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);

    if (!objWord.CreateDispatch("Word.Application.10"))
    {
    AfxMessageBox("Couldn't get Word object.");
    return;
    }

    objWord.SetVisible(TRUE); //This shows the application.

    Documents docs(objWord.GetDocuments());
    _Document myDoc;
    long numCps;
    numCps=1;
    myDoc=docs.Open(COleVariant("c:\\test.doc"));


    myDoc.PrintOut(covTrue, // Background.
    covFalse,//covOptional, // Append.
    COleVariant((long)4),//covOptional, // Range.
    covOptional, // OutputFileName.
    covOptional, // // From.
    covOptional, // // To.
    covOptional, // Item.
    COleVariant((long)numCps), // Copies.
    COleVariant(_T("2,3")),//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);
    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. #18
    Join Date
    Nov 2001
    Posts
    401

    Can you please post your sample project

    As there seems to be something that I am missing.

    I did try this time with a new project just to try it out, but still the same , prints all pages..

    Thanks for your help.. a lot

    Pauli

Page 2 of 2 FirstFirst 12

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