Excel 2007: getItemLabel not working

P

Paul Martin

Hi guys

Based on Jim Rech's dynamic dropdown in Excel 2007, sourced from Andy
Pope's page on the Ribbon, I'm trying to populate a dropdown at
Workbook open. It doesn't really need to be as dynamic as Jim's
example (updates as the list changes). For some reason I can't seem
to get it to work. This is what I have done:

* In XML, I've defined onLoad to run RibbonOnLoad in VBA.
RibbonOnLoad captures the ribbon as a variable.
* In XML, the dropdown's getItemLabel calls GetDropdownList in VBA
* In VBA RefreshRibbon invalidates the ribbon.
* When I invalidate the ribbon (even when manually running
RefreshRibbon), GetDropdownList is not being called.

Can anyone please suggest what I might be doing wrong or what else I
need to do. From Jim Rech's example, I can't see what's wrong.

Thanks in advance

Paul Martin
Melbourne, Australia
 
P

Paul Martin

Oops, I said Andy's page, but actually it was yours, Ron. Pardon moi.

So yes, I'm looking at your code and understand it, but don't seem to
be able to replicate it. FWIW, extracts from the XML and VBA are
below. I'm sure it will look familiar to you.

================================================

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/
customui"
onLoad="RibbonOnLoad">
<ribbon >
<tabs >

<tab id="Production"
label="Production">

<group id="ReportFilters"
label="Report Filters">

<dropDown id="Quarter"
label="Quarter"
getItemLabel="GetDropdownList"
getSelectedItemIndex="GetSelectedItemIndex"
onAction="DropdownOnAction"/>

.....

================================================

Dim Rib As IRibbonUI

Public Sub RibbonOnLoad(Ribbon As IRibbonUI)
Set Rib = Ribbon
End Sub

Public Sub RefreshRibbon()
Rib.Invalidate
End Sub

Sub GetDropdownList(control As IRibbonControl, index As Integer, ByRef
DropdownItem)
DropdownItem = Range("ListQuarters").Columns(1).Cells(index +
1).Value
End Sub

================================================
 
P

Paul Martin

Ron, I've worked it out. I didn't think I needed getItemCount, but
that was the only difference I could ascertain between your code and
mine, and implementing that has worked.

Thanks for your prompt response

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top