Re: Type mismatch error when opening word doc using automation
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Thu, 24 Apr 2008 16:51:18 -0400
I would suggest showing the actual type mismatch error, and possibly the prototype of the
Open method; it would help a lot. Also the prototype for COleVariant; are you sure there
is a version that takes an LPCSTR (as opposed to an LPCTSTR, or possibly an LPWSTR or a
BSTR)
joe
On Thu, 24 Apr 2008 12:38:55 -0700 (PDT), mtuzhilov@xxxxxxxxx wrote:
I get a Type Mismatch error when trying to open word file by usingJoseph M. Newcomer [MVP]
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
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Type mismatch error when opening word doc using automation
- From: mtuzhilov
- Re: Type mismatch error when opening word doc using automation
- References:
- Type mismatch error when opening word doc using automation
- From: mtuzhilov
- Type mismatch error when opening word doc using automation
- Prev by Date: Re: MultibyteToWideChar not working properly?
- Next by Date: Re: creating button in dialog box
- Previous by thread: Type mismatch error when opening word doc using automation
- Next by thread: Re: Type mismatch error when opening word doc using automation
- Index(es):