Group: microsoft.public.word.vba.general
From: "Greg Maxey"
Date: Saturday, March 01, 2008 10:47 PM
Subject: Re: Add Custom Tab Ribbon07 with Multiple DropDowns - Help! PLUS QAT

Summer,

I don't know what to tell you. Like you, I am just stumbling along trying
to learn a bit here and there. Last night I spent hours trying to get a
toggle button to behave properly ;-)

Other that customizing the QAT with the User Interface I haven't messed with
it much. I do know that to customize the QAT with RibbonX you have to use
the StartfromScratch method.

Have you read the Microsoft Articles on Ribbon Customization. There are
links to then on my Customize the Ribbon tips page on my website. You might
find something there.


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Summer wrote:
> Greg,
>
> I've load/unloaded the sample tab numerous times and it now seems to
> a be a little more stable (very unstable this ribbon stuff). Anyway
> I've drag a copy of 3 dds down to the QAT and moved the Addin to
> Startup.
> But I get errors - Runtime error 91
> object variable or with block variable not set
>
> After the case call runs - even though it runs properly. Is it
> something to do with the load/unload to the ribbon QAT do you think?
>
> Do you know why that might be? I realise I didn't mention dragging
> the dds to the QAT but I'm seeing what works and what doesn't.
>
> QAT Customisation
> I tried saving QAT customisation with a template but the trouble with
> that is if a user has a full QAT - your 2 or 3 items which you add to
> a template a user calls are not visible. At the moment I can't see
> this as a very useful option. Do you know if there is an instruction
> as in the True/False to hide Ribbon for QAT - so only the template
> QAT shows and not the user's QAT?
>
> Any assistance much appreciated.
>
> "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.
>>
>>
>> >> xmlns="http://schemas.microsoft.com/office/2006/01/customui"
>> 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."
>>>
>>>
>>>
>>>
>>>
>>> >>> xmlns="http://schemas.microsoft.com/office/2006/01/customui"> >>> startFromScratch="false">
>>>
>>>
>>>
>>>
>>>
>>> >>> label="iLabel">
>>>
>>>

Safety Articles | Usenet Groups | Usenet News | Bluegrass