K
ksun
I use the following code to disable auto macros in the event
OnNavigateComplete2() of CHtmlView, but it seems it does not success.
LPDISPATCH pDispHtmlDocument = GetHtmlDocument();
MSWORD::_Document oDoc = pDispHtmlDocument;
if(oDoc)
{
MSWORD::_Application app = oDoc.GetApplication();
if(app)
{
COleDispatchDriver oWordBasic;
oWordBasic = app.GetWordBasic();
HRESULT hr;
OLECHAR FAR* szMethod[2];
DISPID dispid[2];
szMethod[0] =OLESTR("DisableAutoMacros"); // method name;
//szMethod[1] = OLESTR("Disable");
//szMethod[1] = OLESTR("");
hr = oWordBasic.m_lpDispatch->GetIDsOfNames(IID_NULL, szMethod, 1,
LOCALE_USER_DEFAULT, dispid);
VARIANT vArgs[1];
DISPPARAMS dp;
dp.cArgs = 1;
dp.cNamedArgs = 0;
dp.rgvarg = vArgs;
//dp.rgdispidNamedArgs = &(dispid[1]);
vArgs[0].vt = VT_I2;
vArgs[0].iVal = 1;
VARIANT* pVarResult = NULL;
EXCEPINFO* pExcepInfo = NULL;
UINT* pInt = NULL;
try
{
hr = oWordBasic.m_lpDispatch->Invoke(dispid[0],
IID_NULL,LOCALE_USER_DEFAULT, /*DISPATCH_PROPERTYPUT*/
DISPATCH_METHOD, /*&dpNoArgs*/&dp, pVarResult, pExcepInfo, pInt);
After the method "Invoke", the return value is none of the following
values:
S_OK,
DISP_E_BADPARAMCOUNT,
DISP_E_BADVARTYPE,
DISP_E_EXCEPTION,
DISP_E_MEMBERNOTFOUND,
DISP_E_NONAMEDARGS,
DISP_E_OVERFLOW,
DISP_E_PARAMNOTFOUND,
DISP_E_TYPEMISMATCH,
DISP_E_UNKNOWNINTERFACE,
DISP_E_UNKNOWNLCID,
DISP_E_PARAMNOTOPTIONAL
Is there anything wrong in the above code?
OnNavigateComplete2() of CHtmlView, but it seems it does not success.
LPDISPATCH pDispHtmlDocument = GetHtmlDocument();
MSWORD::_Document oDoc = pDispHtmlDocument;
if(oDoc)
{
MSWORD::_Application app = oDoc.GetApplication();
if(app)
{
COleDispatchDriver oWordBasic;
oWordBasic = app.GetWordBasic();
HRESULT hr;
OLECHAR FAR* szMethod[2];
DISPID dispid[2];
szMethod[0] =OLESTR("DisableAutoMacros"); // method name;
//szMethod[1] = OLESTR("Disable");
//szMethod[1] = OLESTR("");
hr = oWordBasic.m_lpDispatch->GetIDsOfNames(IID_NULL, szMethod, 1,
LOCALE_USER_DEFAULT, dispid);
VARIANT vArgs[1];
DISPPARAMS dp;
dp.cArgs = 1;
dp.cNamedArgs = 0;
dp.rgvarg = vArgs;
//dp.rgdispidNamedArgs = &(dispid[1]);
vArgs[0].vt = VT_I2;
vArgs[0].iVal = 1;
VARIANT* pVarResult = NULL;
EXCEPINFO* pExcepInfo = NULL;
UINT* pInt = NULL;
try
{
hr = oWordBasic.m_lpDispatch->Invoke(dispid[0],
IID_NULL,LOCALE_USER_DEFAULT, /*DISPATCH_PROPERTYPUT*/
DISPATCH_METHOD, /*&dpNoArgs*/&dp, pVarResult, pExcepInfo, pInt);
After the method "Invoke", the return value is none of the following
values:
S_OK,
DISP_E_BADPARAMCOUNT,
DISP_E_BADVARTYPE,
DISP_E_EXCEPTION,
DISP_E_MEMBERNOTFOUND,
DISP_E_NONAMEDARGS,
DISP_E_OVERFLOW,
DISP_E_PARAMNOTFOUND,
DISP_E_TYPEMISMATCH,
DISP_E_UNKNOWNINTERFACE,
DISP_E_UNKNOWNLCID,
DISP_E_PARAMNOTOPTIONAL
Is there anything wrong in the above code?