R
Raj Sahrawat
Hi,
I am trying to do the following
Application.COMAddIns.Ite("MyOfficeAddin.Connect").Object
= Me
in Visual C++ and am not able to set the Object property
of the COMAddin IDispatch.
The interface is defined as such in the ms office tlb file
/*********************************************************
******************************/
[
odl,
uuid(000C033A-0000-0000-C000-000000000046),
helpcontext(0x00035778),
dual,
nonextensible,
oleautomation
]
interface COMAddIn : _IMsoDispObj {
[id(00000000), propget, helpcontext(0x00035779)]
HRESULT Description([out, retval] BSTR* RetValue);
[id(00000000), propput, helpcontext(0x00035779)]
HRESULT Description([in] BSTR RetValue);
[id(0x00000003), propget, helpcontext(0x0003577b)]
HRESULT ProgId([out, retval] BSTR* RetValue);
[id(0x00000004), propget, helpcontext(0x0003577c)]
HRESULT Guid([out, retval] BSTR* RetValue);
[id(0x00000006), propget, helpcontext(0x0003577d)]
HRESULT Connect([out, retval] VARIANT_BOOL*
RetValue);
[id(0x00000006), propput, helpcontext(0x0003577d)]
HRESULT Connect([in] VARIANT_BOOL RetValue);
[id(0x00000007), propget, helpcontext(0x0003577f)]
HRESULT Object([out, retval] IDispatch**
RetValue);
[id(0x00000007), propput, helpcontext(0x0003577f)]
HRESULT Object([in] IDispatch* RetValue);
[id(0x00000008), propget, helpcontext(0x00035781)]
HRESULT Parent([out, retval] IDispatch** retval);
};
/*********************************************************
******************************/
Specifically when i do the following -
VARIANT vObject;
VariantInit(&vObject);
vObject.vt = VT_DISPATCH;
vObject.pdispVal = this; //this is my addIn class that
implements the IID_IDTExtensibility2 interface
hr = PutProperty(vCOMAddin.pdispVal, L"Object",
&vObject); /// this always fails with hr = "0x80020009"
Exception
where PutProperty method is defined as -
/*********************************************************
******************************/
STDMETHODIMP Plugin:utProperty(LPDISPATCH _disp,
LPOLESTR _pname, VARIANT *_pvalue)
{
if( _disp == null )
return( E_POINTER );
if( _pvalue == null )
return( E_POINTER );
DISPID dispid;
HRESULT hr = _disp->GetIDsOfNames(IID_NULL,
&_pname, 1, LOCALE_USER_DEFAULT, &dispid);
if( SUCCEEDED(hr) )
{
DISPID dispidput = DISPID_PROPERTYPUT;
DISPPARAMS dispparams = {NULL, NULL, 1,
1};
dispparams.rgvarg = _pvalue;
dispparams.rgdispidNamedArgs = &dispidput;
if( _pvalue->vt == VT_UNKNOWN || _pvalue-
(_pvalue->vt & VT_BYREF) )
{
hr = _disp->Invoke(dispid,
IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD | DISPATCH_PROPERTYPUTREF,
&dispparams,
NULL, NULL, NULL);
if( SUCCEEDED(hr) )
return( hr );
}
hr = _disp->Invoke(dispid, IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD | DISPATCH_PROPERTYPUT,
&dispparams,
NULL,
NULL, NULL);
}
return( hr );
}
/*********************************************************
******************************/
I am running out of ideas on why this is not working. Any
help would be appreciated.
thanks
-Raj
I am trying to do the following
Application.COMAddIns.Ite("MyOfficeAddin.Connect").Object
= Me
in Visual C++ and am not able to set the Object property
of the COMAddin IDispatch.
The interface is defined as such in the ms office tlb file
/*********************************************************
******************************/
[
odl,
uuid(000C033A-0000-0000-C000-000000000046),
helpcontext(0x00035778),
dual,
nonextensible,
oleautomation
]
interface COMAddIn : _IMsoDispObj {
[id(00000000), propget, helpcontext(0x00035779)]
HRESULT Description([out, retval] BSTR* RetValue);
[id(00000000), propput, helpcontext(0x00035779)]
HRESULT Description([in] BSTR RetValue);
[id(0x00000003), propget, helpcontext(0x0003577b)]
HRESULT ProgId([out, retval] BSTR* RetValue);
[id(0x00000004), propget, helpcontext(0x0003577c)]
HRESULT Guid([out, retval] BSTR* RetValue);
[id(0x00000006), propget, helpcontext(0x0003577d)]
HRESULT Connect([out, retval] VARIANT_BOOL*
RetValue);
[id(0x00000006), propput, helpcontext(0x0003577d)]
HRESULT Connect([in] VARIANT_BOOL RetValue);
[id(0x00000007), propget, helpcontext(0x0003577f)]
HRESULT Object([out, retval] IDispatch**
RetValue);
[id(0x00000007), propput, helpcontext(0x0003577f)]
HRESULT Object([in] IDispatch* RetValue);
[id(0x00000008), propget, helpcontext(0x00035781)]
HRESULT Parent([out, retval] IDispatch** retval);
};
/*********************************************************
******************************/
Specifically when i do the following -
VARIANT vObject;
VariantInit(&vObject);
vObject.vt = VT_DISPATCH;
vObject.pdispVal = this; //this is my addIn class that
implements the IID_IDTExtensibility2 interface
hr = PutProperty(vCOMAddin.pdispVal, L"Object",
&vObject); /// this always fails with hr = "0x80020009"
Exception
where PutProperty method is defined as -
/*********************************************************
******************************/
STDMETHODIMP Plugin:utProperty(LPDISPATCH _disp,
LPOLESTR _pname, VARIANT *_pvalue)
{
if( _disp == null )
return( E_POINTER );
if( _pvalue == null )
return( E_POINTER );
DISPID dispid;
HRESULT hr = _disp->GetIDsOfNames(IID_NULL,
&_pname, 1, LOCALE_USER_DEFAULT, &dispid);
if( SUCCEEDED(hr) )
{
DISPID dispidput = DISPID_PROPERTYPUT;
DISPPARAMS dispparams = {NULL, NULL, 1,
1};
dispparams.rgvarg = _pvalue;
dispparams.rgdispidNamedArgs = &dispidput;
if( _pvalue->vt == VT_UNKNOWN || _pvalue-
(_pvalue->vt & VT_ARRAY) ||vt == VT_DISPATCH ||
(_pvalue->vt & VT_BYREF) )
{
hr = _disp->Invoke(dispid,
IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD | DISPATCH_PROPERTYPUTREF,
&dispparams,
NULL, NULL, NULL);
if( SUCCEEDED(hr) )
return( hr );
}
hr = _disp->Invoke(dispid, IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD | DISPATCH_PROPERTYPUT,
&dispparams,
NULL,
NULL, NULL);
}
return( hr );
}
/*********************************************************
******************************/
I am running out of ideas on why this is not working. Any
help would be appreciated.
thanks
-Raj