|
|
|
date: Mon, 27 Aug 2007 22:46:45 -0400,
group: microsoft.public.platformsdk.com_ole
back
IDispatch and word CheckSpelling problem
Hi,
I'm trying to use CheckSpelling method and have some problems.
I use code below:
CLSID clsid;
CLSIDFromProgID(L"Word.Application", &clsid);
IUnknown* pUnk;
HRESULT hr = ::CoCreateInstance( clsid, NULL, CLSCTX_SERVER,
IID_IUnknown, (void**) &pUnk);
IDispatch* pDispApp;
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&pDispApp);
// Get IDispatch* for the Documents collection object
szFunction = OLESTR("Documents");
hr = pDispApp->GetIDsOfNames (IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_Docs);
hr = pDispApp->Invoke (dispid_Docs, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
&dpNoArgs, &vResult, NULL, NULL);
pDispDocs = vResult.pdispVal;That way I can open word, write text to it,
save it, but have no idea how to call CheckSpelling, when I do this
GetIDsOFNames return some ID but when I callinvoke I'm geting error:
IDispatch* pDispSpell;
szFunction = OLESTR("CheckSpelling"); hr =
pDispDocs->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT,
&dispSpell); hr = pDispApp->Invoke
(dispSpell, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
&dpNoArgs, &vResult, NULL, NULL);All examples on
the net are with VB, very little with C++, any tip how to use that spell
check object?thanks
date: Mon, 27 Aug 2007 22:46:45 -0400
author: Arnold
Re: IDispatch and word CheckSpelling problem
"Arnold" wrote in message
news:OZZau2R6HHA.1184@TK2MSFTNGP04.phx.gbl
> That way I can open word, write text
> to it, save it, but have no idea how to call CheckSpelling, when I do
> this GetIDsOFNames return some ID but when I callinvoke I'm geting
> error: IDispatch* pDispSpell;
> szFunction = OLESTR("CheckSpelling"); hr =
> pDispDocs->GetIDsOfNames(IID_NULL, &szFunction, 1,
> LOCALE_USER_DEFAULT,
> &dispSpell); hr = pDispApp->Invoke
> (dispSpell, IID_NULL,
> LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
> &dpNoArgs, &vResult, NULL, NULL);
CheckSpelling is not a property, it's a method. Try with DISPATCH_INVOKE
in place of DISPATCH_PROPERTYGET.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Tue, 28 Aug 2007 08:17:51 -0400
author: Igor Tandetnik
|
|