Group: microsoft.public.word.vba.general
From: "Summer"
Date: Saturday, March 01, 2008 3:44 PM
Subject: Re: Add Custom Tab Ribbon07 with Multiple DropDowns - Help!

Thank you Greg for being so generous with your time and assisting. I'll see
how I go (splashing all the way) and let you know.



"Greg Maxey" wrote in message
news:eUVtso6eIHA.5160@TK2MSFTNGP05.phx.gbl...
> Summer,
>
> I am not really sure which example of mine that you are referencing but
> since I am learning bits and pieces everyday things often change ;-). I
> am by no means an expert and there is likely a better way. However, this
> is how I would go about creating multiple dropdowns in a group.
>
> First I have learned that it seems to be much easier to use call backs as
> much as possible for defining the Ribbon. Here is the XML that would
> create a custom Tab, with a custom Group, holding four dropdowns. You
> could add as many as you want.
>
>
> > onLoad="Onload">
>
>
>
>
> > getItemCount="GetItemCount" getItemLabel="GetItemLabel"
> getItemImage="GetItemImage" getSelectedItemIndex="GetSelectedItemIndex"
> getItemScreentip="GetItemScreenTip" getItemSupertip="GetItemSuperTip"
> onAction="MyDDMacro">
>

> > getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
> onAction="MyDDMacro">
>

> > getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
> onAction="MyDDMacro">
>

> > getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
> onAction="MyDDMacro">
>

>

>

>

>

>

>
> The first dropdown is a little souped up with extra features while the
> other three contain the bare bones to make them functional.
>
> You will notiice that they all use the same callbacks.
>
> Now in the VBA you simply use the same call backs and the Select Case
> method to deal with each control:
>
> Option Explicit
> Public myRibbon As IRibbonUI
>
> Sub Onload(ribbon As IRibbonUI)
> Set myRibbon = ribbon
> End Sub
>
> Sub MyDDMacro(ByVal control As IRibbonControl, selectedId As String,
> selectedIndex As Integer)
> Select Case control.id
> Case "DD1"
> Select Case selectedIndex
> Case Is = 1
> 'Report some data
> MsgBox "Font name: " & Selection.Font.Name & ". Font size: " &
> Selection.Font.Size
> Case Is = 2
> 'Call a builtin Word command
> Application.Run "ChangeCase"
> Case Is = 3
> 'Call another procedure in this project
> SampleModule.RandomizeCharactersInWordsFirstAndLastExclusive
> End Select
> 'I invalidate the control so that "Select item" reappears after the
> action is taken. You wouldn't do this if you want the selected item to
> remain displayed.
> myRibbon.InvalidateControl control.id
> Case "DD2"
> 'Add another Select Case statement here similiar to the one shown
> above.
> Case "DD3"
>
> Case "DD4"
>
> Case Else
> 'Do Nothing
> End Select
> End Sub
>
> Sub GetSelectedItemIndex(ByVal control As IRibbonControl, ByRef Index)
> Select Case control.id
> Case "DD1"
> Index = 0
> Case "DD2"
> Index = 0
> Case "DD3"
> Index = 0
> Case "DD4"
> Index = 0
> Case Else
> 'Do nothing
> End Select
> End Sub
>
> Sub GetLabel(ByVal control As IRibbonControl, ByRef label)
> Select Case control.id
> Case "DD1"
> label = "Sample Dropdown List 1"
> Case "DD2"
> label = "Sample Dropdown List 2"
> Case "DD3"
> label = "Sample Dropdown List 3"
> Case "DD4"
> label = "Sample Dropdown List 4"
> Case "CustomTab"
> label = "Sample Tab"
> Case "Grp1"
> label = "Sample Group"
> Case Else
> 'Do Nothing
> End Select
> End Sub
>
> Sub GetItemLabel(ByVal control As IRibbonControl, Index As Integer, ByRef
> label)
> Select Case control.id
> Case "DD1"
> Select Case Index
> Case Is = 0
> label = "Select Item"
> Case Is = 1
> label = "Item 1"
> Case Is = 2
> label = "Item 2"
> Case Is = 3
> label = "Item 3"
> End Select
> Case "DD2"
> Select Case Index
> Case Is = 0
> label = "Select Item"
> Case Is = 1
> label = "Item 1"
> End Select
> Case "DD3"
> Select Case Index
> Case Is = 0
> label = "Select Item"
> Case Is = 1
> label = "Item 1"
> Case Is = 2
> label = "Item 2"
> End Select
> Case "DD4"
> Select Case Index
> Case Is = 0
> label = "Select Item"
> Case Is = 1
> label = "Item 1"
> Case Is = 2
> label = "Item 2"
> Case Is = 3
> label = "Item 3"
> Case Is = 4
> label = "Item 4"
> Case Is = 5
> label = "Item 5"
> End Select
> Case Else
> '"Do Nothing"
> End Select
> End Sub
>
> Sub GetItemImage(ByVal control As IRibbonControl, Index As Integer, ByRef
> image)
> Select Case control.id
> Case "DD1"
> Select Case Index
> Case Is = 0
> image = "OutlineCollapse"
> Case Is = 1
> image = "FileStartWorkflow"
> Case Is = 2
> image = "FileStartWorkflow"
> Case Is = 3
> image = "FileStartWorkflow"
> End Select
> Case Else
> 'Do Nothing
> End Select
> End Sub
>
> Sub GetItemID(ByVal control As IRibbonControl, Index As Integer, ByRef id)
> Select Case control.id
> Case "DD1"
> Select Case Index
> Case Is = 0
> id = "DD1"
> Case Is = 1
> id = "DD2"
> Case Is = 2
> id = "DD3"
> Case Is = 3
> id = "DD4"
> End Select
> Case Else
> 'Do Nothing
> End Select
> End Sub
>
> Sub GetItemCount(ByVal control As IRibbonControl, ByRef count)
> Select Case control.id
> Case "DD1"
> count = 4
> Case "DD2"
> count = 2
> Case "DD3"
> count = 3
> Case "DD4"
> count = 5
> Case Else
> 'Do Nothing
> End Select
> End Sub
>
> Sub GetImage(ByVal control As IRibbonControl, ByRef image)
> Select Case control.id
> Case "DD1"
> image = "ContentControlDropDownList"
> Case Else
> 'Do Nothing
> End Select
> End Sub
>
> Sub GetItemScreenTip(ByVal control As IRibbonControl, Index As Integer,
> ByRef screentip)
> Select Case control.id
> Case "DD1"
> Select Case Index
> Case Is = 0
> screentip = "This is the default displayed item."
> Case Is = 1
> screentip = "Select this second item to do ..."
> Case Is = 2
> screentip = "Select this thrid item to do ..."
> Case Is = 3
> screentip = "Select this fourth item to do ..."
> End Select
> Case Else
> 'Do Nothing
> End Select
> End Sub
>
> Sub GetItemSuperTip(ByVal control As IRibbonControl, Index As Integer,
> ByRef supertip)
> Select Case control.id
> Case "DD1"
> Select Case Index
> Case Is = 0
> supertip = "This is the Supertip text: Blah, blah, blah."
> Case Is = 1
> supertip = "This is the Supertip text: Blah, blah, blah."
> Case Is = 2
> supertip = "This is the Supertip text: Blah, blah, blah."
> Case Is = 3
> supertip = "This is the Supertip text: Blah, blah, blah."
> End Select
> Case Else
> 'Do Nothing
> End Select
> End Sub
>
> Hope this gets you on course.
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Greg Maxey - Word MVP
>
> My web site http://gregmaxey.mvps.org
> Word MVP web site http://word.mvps.org
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> "Summer" wrote in message
> news:OJ8EYd5eIHA.2000@TK2MSFTNGP03.phx.gbl...
>> Help please - throwing myself in at deep end and dog paddling to create a
>> working Custom Tab with multiple dropdowns plus buttons!
>>
>>
>>
>> I'm cobbling together a custom Tab but wanting multiple dropdowns (not
>> just one) and ideas on VBA of how to simplify all the dropdowns in the
>> one Ribbon Module. All my dropdowns have loaded in the TAB as they should
>> but I'm just not sure how to approach the VBA Ribbon Module to cope with
>> multiple Dropdown IDs and macros?
>>
>>
>>
>> Based on Greg Maxey's dropdown sample - does anyone have any ideas how to
>> best simplify the module RibbonControl (Greg?) to incorporate ALL
>> groupids: DD DD1 DD2 in the VBA project? I'm going to have about 15
>> dropdowns all up - my working macro Custom Tab."
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> >> label="iLabel">
>>
>>

Safety Articles | Usenet Groups | Usenet News | Bluegrass