N
NickP
Hi there,
First thing I wanted to mention, just an observation, is how different
the COM automation is between applications in MS Office. I am making a
shared add-in which requires printing and it really shows to lack of
continuity between the applications. The worst of which is Word which has 3
Print methods, PrintOutOld, PrintOut2000 and PrintOut. The closest app is
Excel which accepts a load of Variants but it also accepts BSTR arguments,
which Word does not, it uses VARIANT type instead. Anyway...
Unfortunately Word refuses to print.
If I just call PrintOut with no arguments it crashes with an unhelpful
error message. If I use the following parameters
//cDPPPrinter->getOutputFileName() == CString "c:\myfile.tmp"
VARIANT pVarAppend; pVarAppend.boolVal = FALSE;
VARIANT pVarPrintToFile; pVarPrintToFile.boolVal = TRUE;
VARIANT pVarOutputFileName; pVarOutputFileName.bstrVal =
cDPPPrinter->getOutputFileName().AllocSysString();
if(S_OK==pDPrDocument->PrintOut(&vtMissing, &pVarAppend, &vtMissing,
&pVarOutputFileName, &vtMissing, &vtMissing, &vtMissing, &vtMissing,
&vtMissing, &vtMissing, &pVarPrintToFile))
//Exception occurs here
An error occurs on line 788 of atlsimpstr.h when the PrintOut method is
called
m_pszData = static_cast< PXSTR >( pData->data());
I'm presuming that this is possibly down to the way I have assigned
pVarOutputFileName? Any ideas what I am doing wrong here? I have the code
working from VB.NET via just calling PrintOut yet in C++ it is a complete
nightmare!.
So yeah, just incase, I'm using VC 2005 via the shared add-in template.
Nick.
First thing I wanted to mention, just an observation, is how different
the COM automation is between applications in MS Office. I am making a
shared add-in which requires printing and it really shows to lack of
continuity between the applications. The worst of which is Word which has 3
Print methods, PrintOutOld, PrintOut2000 and PrintOut. The closest app is
Excel which accepts a load of Variants but it also accepts BSTR arguments,
which Word does not, it uses VARIANT type instead. Anyway...
Unfortunately Word refuses to print.
If I just call PrintOut with no arguments it crashes with an unhelpful
error message. If I use the following parameters
//cDPPPrinter->getOutputFileName() == CString "c:\myfile.tmp"
VARIANT pVarAppend; pVarAppend.boolVal = FALSE;
VARIANT pVarPrintToFile; pVarPrintToFile.boolVal = TRUE;
VARIANT pVarOutputFileName; pVarOutputFileName.bstrVal =
cDPPPrinter->getOutputFileName().AllocSysString();
if(S_OK==pDPrDocument->PrintOut(&vtMissing, &pVarAppend, &vtMissing,
&pVarOutputFileName, &vtMissing, &vtMissing, &vtMissing, &vtMissing,
&vtMissing, &vtMissing, &pVarPrintToFile))
//Exception occurs here
An error occurs on line 788 of atlsimpstr.h when the PrintOut method is
called
m_pszData = static_cast< PXSTR >( pData->data());
I'm presuming that this is possibly down to the way I have assigned
pVarOutputFileName? Any ideas what I am doing wrong here? I have the code
working from VB.NET via just calling PrintOut yet in C++ it is a complete
nightmare!.
So yeah, just incase, I'm using VC 2005 via the shared add-in template.
Nick.