Click here to Skip to main content
15,914,222 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalevents problem.... Pin
Neha3-Apr-02 2:53
Neha3-Apr-02 2:53 
Generalremove item from std::list Pin
3-Apr-02 2:46
suss3-Apr-02 2:46 
GeneralRe: remove item from std::list Pin
Chris Losinger3-Apr-02 3:11
professionalChris Losinger3-Apr-02 3:11 
GeneralRe: remove item from std::list Pin
Christian Graus3-Apr-02 9:47
protectorChristian Graus3-Apr-02 9:47 
GeneralRe: remove item from std::list Pin
Chris Losinger3-Apr-02 9:56
professionalChris Losinger3-Apr-02 9:56 
GeneralRe: remove item from std::list Pin
3-Apr-02 3:47
suss3-Apr-02 3:47 
GeneralRe: remove item from std::list Pin
Jack Handy3-Apr-02 4:46
Jack Handy3-Apr-02 4:46 
GeneralPrinting with MS Word Automation Pin
3-Apr-02 1:59
suss3-Apr-02 1:59 
I've made a MS Word automation project in order to print it's content
into Acrobat Distiller.
I want to print 3 pages (nPages = 3).

//---------------------------------------------------------------------------------------------------------------------------------------
So, my method is :

void _Document::PrintOut(VARIANT* Background,
VARIANT* Append,
VARIANT* Range,
VARIANT* OutputFileName,
VARIANT* From,
VARIANT* To,
VARIANT* Item,
VARIANT* Copies,
VARIANT* Pages,
VARIANT* PageType,
VARIANT* PrintToFile,
VARIANT* Collate,
VARIANT* ActivePrinterMacGX,
VARIANT* ManualDuplexPrint,
VARIANT* PrintZoomColumn,
VARIANT* PrintZoomRow,
VARIANT* PrintZoomPaperWidth,
VARIANT* PrintZoomPaperHeight )
{
static BYTE parms[] =
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT;
InvokeHelper(0x1bc, DISPATCH_METHOD, VT_EMPTY, NULL, parms, Background,
Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType,
PrintToFile, Collate, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn,
PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------
And, the following call to this method produces an exception, cause of COleVariant(nPages,VT_I4)

CString text;
m_Edit.GetWindowText(text);

_Application objWord;
// Convenient values declared as ColeVariants.
COleVariant covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
// Get the IDispatch pointer and attach it to the objWord object.
if (!objWord.CreateDispatch("Word.Application"))
{
AfxMessageBox("Couldn't get Word object.");
return;
}
objWord.SetVisible(TRUE); //This shows the application.
Documents docs(objWord.GetDocuments());
_Document testDoc;
testDoc.AttachDispatch(docs.Open
(
COleVariant(text,VT_BSTR),
covFalse, // Confirm Conversion.
covFalse, // ReadOnly.
covFalse, // AddToRecentFiles.
covOptional, // PasswordDocument.
covOptional, // PasswordTemplate.
covFalse, // Revert.
covOptional, // WritePasswordDocument.
covOptional, // WritePasswordTemplate.
covOptional, covOptional, covOptional), // Format. // Last argument for Word 97
(long)1 // Encoding // New for Word 2000/2002
); // Close AttachDispatch(.)

objWord.SetActivePrinter("Acrobat Distiller");

long nPages = 3;
SCODE sc;
TRY
{
testDoc.PrintOut(covFalse, // Background.
covOptional, // Append.
covOptional, // Range.
covOptional, // OutputFileName.
covOptional, // From.
covOptional, // To.
covOptional, // Item.
covOptional, // Copies.
COleVariant(nPages,VT_I4), // Pages.
covOptional, // PageType.
covOptional, // PrintToFile.
covOptional, // Collate.
covOptional, // ActivePrinterMacGX.
covOptional, // ManualDuplexPrint.
covOptional, // PrintZoomColumn New with Word 2002
covOptional, // PrintZoomRow ditto
covOptional, // PrintZoomPaperWidth ditto
covOptional); // PrintZoomPaperHeight ditto


objWord.Quit(covFalse, // SaveChanges.
covTrue, // OriginalFormat.
covFalse // RouteDocument.
);
sc = S_OK;
}

CATCH_ALL(e)
{
sc = COleException::Process(e);
CString exp;
exp.Format("%d", e);
MessageBox(exp, "Exception !");
}
END_CATCH_ALL

How can i do ?
Thanks.
Frown | :(
GeneralString -> char * Pin
Chris Coote3-Apr-02 1:57
Chris Coote3-Apr-02 1:57 
QuestionApp wants to know: Is cursor off me now? Pin
Rickard Andersson203-Apr-02 1:36
Rickard Andersson203-Apr-02 1:36 
AnswerRe: App wants to know: Is cursor off me now? Pin
Mazdak3-Apr-02 1:47
Mazdak3-Apr-02 1:47 
GeneralRe: App wants to know: Is cursor off me now? Pin
Rickard Andersson203-Apr-02 1:50
Rickard Andersson203-Apr-02 1:50 
GeneralRe: App wants to know: Is cursor off me now? Pin
Mazdak3-Apr-02 1:55
Mazdak3-Apr-02 1:55 
GeneralRe: App wants to know: Is cursor off me now? Pin
alex.barylski3-Apr-02 3:13
alex.barylski3-Apr-02 3:13 
GeneralRe: App wants to know: Is cursor off me now? Pin
Jack Handy3-Apr-02 5:25
Jack Handy3-Apr-02 5:25 
GeneralOpenGL in MDI Apps under Windows 2000 Pin
v_krishnan3-Apr-02 0:56
v_krishnan3-Apr-02 0:56 
GeneralRefreshing View From Tree Selection Pin
3-Apr-02 0:42
suss3-Apr-02 0:42 
GeneralRe: Refreshing View From Tree Selection Pin
3-Apr-02 2:15
suss3-Apr-02 2:15 
GeneralRe: Refreshing View From Tree Selection Pin
undeadhamster3-Apr-02 2:38
undeadhamster3-Apr-02 2:38 
GeneralDBGrid Pin
Drawil3-Apr-02 0:13
Drawil3-Apr-02 0:13 
GeneralExact Caret Position in the Rich Edit Control Pin
internal2-Apr-02 23:51
internal2-Apr-02 23:51 
GeneralRe: Exact Caret Position in the Rich Edit Control Pin
alex.barylski3-Apr-02 0:17
alex.barylski3-Apr-02 0:17 
General3D graphics question Pin
alex.barylski2-Apr-02 23:49
alex.barylski2-Apr-02 23:49 
GeneralRe: 3D graphics question Pin
Paul M Watt3-Apr-02 5:54
mentorPaul M Watt3-Apr-02 5:54 
GeneralNetwork Card packet Programm! Pin
Reza Azizi2-Apr-02 23:28
Reza Azizi2-Apr-02 23:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.