Resetting Dropdown list in Ribbon

P

Peter Karlström

Hi

In one of our VBA-projects we have customized a ribbon tab with the Office
2007 Custom UI Editor. The resulting xml-code shows below:

+++Start Code+++
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="MyAddInInitialize">
<ribbon startFromScratch="false">
<tabs>
<tab id="customTab" label="Custom Tab">
<group id="customGroup" label="Protokoll">
<box id="box1" boxStyle="vertical">
<dropDown id="DropDown1" label="Format"
onAction="ThisDocument.FMFormat" >
<item id="DropdownList1" label="Normal"/>
<item id="DropdownList2" label="Heading 1" />
<item id="DropdownList3" label="Heading 2"/>
<item id="DropdownList4" label="Heading 3" />
</dropDown>
<dropDown id="DropDown2" label="Specialformat"
onAction="ThisDocument.FMInfo">
<item id="ListDropdown1" label="Meeting list" />
<item id="ListDropdown2" label="Notes" />
<item id="ListDropdown3" label="Notes descision" />
<item id="ListDropdown4" label="Notes reviewer" />
</dropDown>
<button id="customButton2" label="Insert heading" size="normal"
onAction="ThisDocument.InfogaNyPunkt" />
<button id="customButton3" label="Change/Show properties"
size="normal" onAction="ThisDocument.VisaDialog" />
</box>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
+++ End code+++

In a macro-enabled document template we have made all functions avialable
and everything works fine, if it was not for the behaviour of the dropdown
lists.
If the user makes a choice from the list, the code executes just fine but
the selected item remains selected. We have looked everywhere to find a way
to "reset" the dropdown list to its original value, but we have found nothing.

The ribbon is made public with the following line:
Public MyRibbon As IRibbonUI

In the initialization of the Addin the MyRibbon is set with the following
line:
Set MyRibbon = Ribbon

When the user uses the dropdown list the following proc take action:
Public Sub FMFormat(control As IRibbonControl, selectedID As String,
selectedIndex As Integer)

We have tried the following:
MyRibbon.InvalidateControl (control.ID) does not seems to work.
MyRibbon.Invalidate does not seem to work either.
MyRibbon.Refresh method found in some hints is not valid.

What can we do about this? Anybody?

Thanks in advance
 
J

\Ji Zhou [MSFT]\

Hello Peter,

Nice to see you again. This is Ji Zhou [MSFT] and I will be working on this
issue with you.

Based on my understanding, the issue is when we are manipulating the
dropdown control in the Office ribbon. The item which appears in the UI is
always what we have newly selected, but we are trying to reset it to the
original item, right? If I have misunderstood the issue, please feel free to
let me know.

Actually, the Invalidate() function of the IRibbonUI instance only causes
the ribbon/controls callback functions executed. So, if we do not implement
a control’s callback function like getLabel, getVisible,
getSelectedItemIndex, nothing will happen when we call the
IRibbonUI.Invalidate().

Thus, my resolution is as follows, please let me know if it helps for your
scenario. And if you need any future help, please feel free to contact me.

1.We implement the dropdown’s getSelectedItemIndex callback function, so we
have the following xml file,

<dropDown id="DropDown1" label="Format"
getSelectedItemIndex="GetSelectedItem"
onAction="ThisDocument.FMFormat" >
<item id="DropdownList1" label="Normal"/>
<item id="DropdownList2" label="Heading 1" />
<item id="DropdownList3" label="Heading 2"/>
<item id="DropdownList4" label="Heading 3" />
</dropDown>

2.Implement the callback function in VBA as the following. Setting the
returnedVal to 0 means that we want to show the first item in our dropdown
control

Sub GetSelectedItem(control As IRibbonControl, ByRef returnedVal)
returnedVal = 0
End Sub

3.In, the dropdown’s onAction callback function, we invalidate the ribbon
control as you did,

Sub FMFormat(control As IRibbonControl, id As String, index As Integer)
MyRibbon.InvalidateControl (control.id)
End Sub


Best regards,
Ji Zhou ([email protected], remove ‘online.’)
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Karlström

Hello Ji Zhou

Thank you for the quick reaply.

This was exactly what I was looking for. Now it's working just like we
wanted it to do.

Best Regards
--
Peter Karlström
Midrange AB
Sweden


"Ji Zhou [MSFT]" said:
Hello Peter,

Nice to see you again. This is Ji Zhou [MSFT] and I will be working on this
issue with you.

Based on my understanding, the issue is when we are manipulating the
dropdown control in the Office ribbon. The item which appears in the UI is
always what we have newly selected, but we are trying to reset it to the
original item, right? If I have misunderstood the issue, please feel free to
let me know.

Actually, the Invalidate() function of the IRibbonUI instance only causes
the ribbon/controls callback functions executed. So, if we do not implement
a control’s callback function like getLabel, getVisible,
getSelectedItemIndex, nothing will happen when we call the
IRibbonUI.Invalidate().

Thus, my resolution is as follows, please let me know if it helps for your
scenario. And if you need any future help, please feel free to contact me.

1.We implement the dropdown’s getSelectedItemIndex callback function, so we
have the following xml file,

<dropDown id="DropDown1" label="Format"
getSelectedItemIndex="GetSelectedItem"
onAction="ThisDocument.FMFormat" >
<item id="DropdownList1" label="Normal"/>
<item id="DropdownList2" label="Heading 1" />
<item id="DropdownList3" label="Heading 2"/>
<item id="DropdownList4" label="Heading 3" />
</dropDown>

2.Implement the callback function in VBA as the following. Setting the
returnedVal to 0 means that we want to show the first item in our dropdown
control

Sub GetSelectedItem(control As IRibbonControl, ByRef returnedVal)
returnedVal = 0
End Sub

3.In, the dropdown’s onAction callback function, we invalidate the ribbon
control as you did,

Sub FMFormat(control As IRibbonControl, id As String, index As Integer)
MyRibbon.InvalidateControl (control.id)
End Sub


Best regards,
Ji Zhou ([email protected], remove ‘online.’)
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
E

Eef

Hello Ji Zhou,

I have the same issue, but I do not want the drop down menu reset to the
first item in the drop down menu, I want it empty again, like it was when I
started. Is that possible as well?

Kind regards,

Eef
 
L

liebesiech

Like this?
Sub GetSelectedItem(control As IRibbonControl, ByRef returnedVal)
returnedVal = -1
End Sub

René
 

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