Re: Type mismatch error when opening word doc using automation
On Apr 24, 3:51 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
I would suggest showing the actual type mismatch error, and possibly the p=
rototype of the
Open method; it would help a lot. Also the prototype for COleVariant; a=
re you sure there
is a version that takes an LPCSTR (as opposed to an LPCTSTR, or possibly a=
n LPWSTR or a
BSTR)
=
joe
On Thu, 24 Apr 2008 12:38:55 -0700 (PDT), mtuzhi...@gmail.com wrote:
I get a Type Mismatch error when trying to open word file by using
automation. I am using msword.h header from Office 2007 and compiling
with VC++ 6.0.
CoInitialize(0);
_Application oWord ;
Documents oDocs;
_Document oDoc;
COleVariant vOpt(DISP_E_PARAMNOTFOUND, VT_ERROR); //For optional args
//Start Word
if(!(oWord.CreateDispatch("Word.Application", NULL)))
{
AfxMessageBox("Error starting Word.", MB_SETFOREGROUND);
return 0;
}
//Open a document
oDocs = oWord.GetDocuments();
//error happens on this line
oDoc = oDocs.Open(COleVariant("C:\\PROJECTS\\RRD_OFFICE2007\
\test.rtf"), vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt,
vOpt,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt);
Does any one have an idea?
Thanks
Joseph M. Newcomer [MVP]
email: newco...@flounder.com
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm- Hide quoted text -
- Show quoted text -
This error is called. Run-time error '13': Type Mismatch. Here is a
link to msword.h, it contains the open method that i am using:
http://www.koders.com/cpp/fid370AD5EFB3C6A2E188159CCF3AD6900AB213B121.aspx.
I think the call is correct, i followed number of guides on the word
automation with mfc. Here is one of them on word autimation:
http://support.microsoft.com/kb/252719.
It works correctly when running from the stand along win32 consol
application but starts complaining about "Type mismatch" when running
in the DLL called by the windows service.
Thanks for any help on this.