getSelectedItem does not work in unmanaged Com-Add In

  • Thread starter Thread starter Peter Marchert
  • Start date Start date
P

Peter Marchert

Hello,

I try to set the default value for a dropdown control in a ribbon.
This is the xml part of the dropdown:

<dropDown id="dropDownControl"
getSelectedItemIndex="CallBackSelectedItemIndex"
onAction="CallBackOnAction"
visible="true">
<item id="dropDownItem0" label="Test1" />
<item id="dropDownItem1" label="Test2" />
<item id="dropDownItem2" label="Test3" />
</dropDown>

The callback procedure "onAction" does always work but the
getSelectedItemIndex (same for getSelectedItemID) does not work
correctly.

Here are some examples of the definition for the callback procedure
which works (the message box appears):

Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl)
MsgBox Ctrl.id
End Sub

Public Sub CallBackSelectedItemIndex(ByVal Ctrl As IRibbonControl)
MsgBox Ctrl.id
End Sub

Public Sub CallBackSelectedItemIndex(ByRef Ctrl As IRibbonControl)
MsgBox Ctrl.id
End Sub

But if a second parameter is used the message box will not appear. I
tried this combinations:

Public Sub CallBackSelectedItemIndex(ByVal Ctrl As IRibbonControl,
ByRef Index)
Public Sub CallBackSelectedItemIndex(ByRef Ctrl As IRibbonControl,
ByRef Index)
Public Sub CallBackSelectedItemIndex(ByRef Ctrl As IRibbonControl,
ByRef Index As Integer)
Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl, Index)
Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl, Index As
Integer)
Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl, Index As
Long)
Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl, ByRef
Index As Integer)
Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl, ByRef
Index As Long)
Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl, ByRef
Index As Byte)
Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl, ByRef
Index As Single)
Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl, ByRef
Index As Double)
Public Sub CallBackSelectedItemIndex(Ctrl As IRibbonControl, ByRef
Index As String)
Public Sub CallBackSelectedItemIndex(ByVal Ctrl As IRibbonControl,
ByRef Index As Variant)

I'm using the Office Developer XP to create Com-Add-Ins and designed
it under Microsoft Outlook 2002. To use the ribbons I have implemented
this type library: http://xldennis.wordpress.com/2006/...dalone-type-library-for-iribbonextensibility/

Is it possible that this library is not correct/complete (it is from
2006)?

I worked on this problem now for 2 days and wonder that other users
does not have this problem. Can somebody who uses VB6 try this example
and report if it works with it?

Thanks
Peter
 
Dennis's tlb has nothing to do with callback signatures for various ribbon
control callbacks. It has the interface definitions of the ribbon
(IRibbonControl, IRibbonExtensibility and IRibbonUI), that's it. The ribbon
callbacks are controlled and validated by the ribbon schema.

The signature for that callback for VB6/VBA would be:

Sub CallBackSelectedItemIndex(ByVal control As IRibbonControl, ByRef
index As Integer)
 
Dennis's tlb has nothing to do with callback signatures for various ribbon
control callbacks. It has the interface definitions of the ribbon
(IRibbonControl, IRibbonExtensibility and IRibbonUI), that's it.

Thanks Ken, that saves me the time to create a new one and try it with
this.
The ribbon callbacks are controlled and validated by the ribbon schema.

I use this one: http://schemas.microsoft.com/office/2006/01/customui
and this works fine e. g. in a normal Excel file.
The signature for that callback for VB6/VBA would be:

    Sub CallBackSelectedItemIndex(ByVal control As IRibbonControl, ByRef
index As Integer)

Thank you but also with exactly this definition it will not work.

Seems it has something to do with my develop environment that I cannot
fix. May be this can some one confirm who created an unmanaged Com-Add
In too but the geSelectedItemIndex callback will work fine.

Thanks
Peter
 
That's the correct schema to use for Office 2007.

I haven't personally used any ribbon drop-down controls in any of my addins,
managed or unmanaged. I usually don't like the way they work, instead I've
used dynamicMenu controls for what I've had to do.

I'll see if I get a chance today or tomorrow to hack your ribbon code into a
test addin in VB6 I use to play with things and see what happens. I'll let
you know.




Dennis's tlb has nothing to do with callback signatures for various ribbon
control callbacks. It has the interface definitions of the ribbon
(IRibbonControl, IRibbonExtensibility and IRibbonUI), that's it.

Thanks Ken, that saves me the time to create a new one and try it with
this.
The ribbon callbacks are controlled and validated by the ribbon schema.

I use this one: http://schemas.microsoft.com/office/2006/01/customui
and this works fine e. g. in a normal Excel file.
The signature for that callback for VB6/VBA would be:

Sub CallBackSelectedItemIndex(ByVal control As IRibbonControl, ByRef
index As Integer)

Thank you but also with exactly this definition it will not work.

Seems it has something to do with my develop environment that I cannot
fix. May be this can some one confirm who created an unmanaged Com-Add
In too but the geSelectedItemIndex callback will work fine.

Thanks
Peter
 
That's the correct schema to use for Office 2007.

I haven't personally used any ribbon drop-down controls in any of my addins,
managed or unmanaged. I usually don't like the way they work, instead I've
used dynamicMenu controls for what I've had to do.

May be this will do my job too. I will have a look at it, thank you.
I'll see if I get a chance today or tomorrow to hack your ribbon code into a
test addin in VB6 I use to play with things and see what happens. I'll let
you know.

That would be very kind of you.

Thank you
Peter
 
It looks like the signature that we both found for that callback is for VBA,
not for VB6. For VB6 it's a Function that returns an Integer, not a Sub.

Here is the signature for the callback in VB6, which I tested with my test
addin and which works:

Function GetSelectedItemIndex(control As IRibbonControl) As Integer

See http://msdn.microsoft.com/en-us/library/aa722523.aspx for a complete
list of callback signatures for various languages, including VB6. Make sure
you use those signatures and not the ones for VBA.
 
It looks like the signature that we both found for that callback is for VBA,
not for VB6. For VB6 it's a Function that returns an Integer, not a Sub.

That's it! Thank you very, very much for your help!

Peter
Here is the signature for the callback in VB6, which I tested with my test
addin and which works:

    Function GetSelectedItemIndex(control As IRibbonControl) As Integer

Seehttp://msdn.microsoft.com/en-us/library/aa722523.aspxfor a complete
list of callback signatures for various languages, including VB6. Make sure
you use those signatures and not the ones for VBA.





That's the correct schema to use for Office 2007.
I haven't personally used any ribbon drop-down controls in any of my
addins, managed or unmanaged. I usually don't like the way they work,
instead I've used dynamicMenu controls for what I've had to do.
I'll see if I get a chance today or tomorrow to hack your ribbon code into
a test addin in VB6 I use to play with things and see what happens. I'll
let you know.
On 12 Aug., 22:04, "Ken Slovak - [MVP - Outlook]" <[email protected]>
wrote:
Dennis's tlb has nothing to do with callback signatures for various
ribbon
control callbacks. It has the interface definitions of the ribbon
(IRibbonControl, IRibbonExtensibility and IRibbonUI), that's it.
Thanks Ken, that saves me the time to create a new one and try it with
this.
I use this one:http://schemas.microsoft.com/office/2006/01/customui
and this works fine e. g. in a normal Excel file.
Thank you but also with exactly this definition it will not work.
Seems it has something to do with my develop environment that I cannot
fix. May be this can some one confirm who created an unmanaged Com-Add
In too but the geSelectedItemIndex callback will work fine.
 
Back
Top