Hi all,
I am trying to get a pointer to the OFFICE IRibbonUI Interface using the CoGetObject API in the code below but the last OUT argument (ByRef ppv As Any) of the CoGetObject function returns an UnKnown type or an Object type instead of IRibbonUI type .
Can anyone shed a light on this ?
Thank you.
Code:Option Explicit Private Type GUID data1 As Long data2 As Integer data3 As Integer data4(7) As Byte End Type Private Declare Function IIDFromString Lib "Ole32" ( _ ByVal lpszIID As Long, _ iid As Any) As Long Private Declare _ Function CoGetObject Lib "Ole32" ( _ ByVal pszName As Long, _ ByVal pBindOptions As Long, _ ByRef riid As GUID, _ ByRef ppv As Any) As Long Sub Test() Dim iRibbon As IUnknown ' As Object Dim iid As GUID Dim hRes As Long Const IID_UNKNOWN As String = "{00000000-0000-0000-C000-000000000046}" 'Iunknown Interface GUID. 'get the iunknown interface hRes = IIDFromString(StrPtr(IID_UNKNOWN), iid) 'get pointer to the iRibbonUI interface '"{926749fa-2615-4987-8845-c33e65f2b957}" = UIRibbonFramework ClassID hRes = CoGetObject(StrPtr("new:926749fa-2615-4987-8845-c33e65f2b957"), 0, iid, iRibbon) MsgBox TypeName(iRibbon) '<=== Should return IRibbonUI but returns UnKnown End Sub




Reply With Quote