August 26th, 1999, 09:24 AM
I am trying to insert a file into an existing word document (the file to be inserted is a word document as well). I created a Range object (used msword8.olb) and after strugging with the param conversion I came up with the following:
//dispatch interface
LPDISPATCH wordDisp=pActiveItem->GetIdispatch();
_Document wordDoc(wordDisp); //valid
Range rangeDoc(wordDisp); //valid??
if (wordDisp!=NULL)
{
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
COleVariant covFalse((short)FALSE);
CString csFile="docinsert.doc";
rangeDoc.InsertFile(csFile,&covOptional,&covOptional,&covOptional,&covOptional);
}
the InsertFile fails with invalid number of parameters. The dispatch interface is valid as I am able to use the wordDoc object to save the file being edited in my application. Any help would be appreciated.
//dispatch interface
LPDISPATCH wordDisp=pActiveItem->GetIdispatch();
_Document wordDoc(wordDisp); //valid
Range rangeDoc(wordDisp); //valid??
if (wordDisp!=NULL)
{
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
COleVariant covFalse((short)FALSE);
CString csFile="docinsert.doc";
rangeDoc.InsertFile(csFile,&covOptional,&covOptional,&covOptional,&covOptional);
}
the InsertFile fails with invalid number of parameters. The dispatch interface is valid as I am able to use the wordDoc object to save the file being edited in my application. Any help would be appreciated.