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."



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

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

<ribbon startFromScratch="false">

<tabs>

<tab id="Test" label="Test">

<group id="iTest"
label="iLabel">

<button id="Btn1" label="2
Spaces . ? ! Clean" size="large" image="image1" onAction="Doc_Clean"/>

<button
idMso="StylesModifyStyle" />

<dropDown id="DD" label="M1"
onAction="GetDDIndex" getItemCount= "GetDDCount" getItemLabel="GetDDLabels">

</dropDown>

<dropDown
id="DD1" label="M2" onAction="GetDDIndex" getItemCount= "GetDDCount"
getItemLabel="GetDDLabels">

</dropDown>



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

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

<ribbon startFromScratch="false">

<tabs>

<tab id="Test" label="Test">

<group id="iTest"
label="iLabel">

<button id="Btn1" label="2
Spaces . ? ! Clean" size="large" image="image1" onAction="Doc_Clean"/>

<button
idMso="StylesModifyStyle" />

<dropDown id="DD" label="M1"
onAction="GetDDIndex" getItemCount= "GetDDCount" getItemLabel="GetDDLabels">

</dropDown>

<dropDown
id="DD1" label="M2" onAction="GetDDIndex" getItemCount= "GetDDCount"
getItemLabel="GetDDLabels">

</dropDown>



Et cetera....



Code Module which needs to be expanded on to include ALL the IDs for
dropdowns and Cases for the macros - Am I being too simplistic expecting the
macros to be sequential Macro1 to Macro50 and expecting to modify the DD
Id?:



Option Explicit

Sub GetDDIndex(ByVal control As IRibbonControl, selectedID As String, _
selectedIndex As Integer)
Select Case selectedIndex
Case 0
Macros.Macro1
Case 1
Macros.Macro2
Case 2
Macros.Macro3
Case 3
Macros.Macro4
Case 4
Macros.Macro5

Case 5
Macros.Macro6

Case 6
Macros.Macro7

End Select
End Sub

Sub GetDDCount(ByVal control As IRibbonControl, ByRef count)
count = 7
End Sub

Sub GetDDLabels(ByVal control As IRibbonControl, _
index As Integer, ByRef label)
Dim i As Long
For i = 0 To index
label = Choose(i + 1, "Clear Text", _
"Macro Clear FR", _
"Macro 3", _
"Macro 4", _
"Macro 5", _
"Macro 6", _
"Macro 7")
Next i
End Sub

Sub Doc_Clean(ByVal control As IRibbonControl)
Macros.Doc_Clean
End Sub

Re: Add Custom Tab Ribbon07 with Multiple DropDowns - Help! by Greg

Greg
Sat Mar 01 06:40:25 PST 2008

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.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="Onload">
<ribbon>
<tabs>
<tab id="CustomTab" getLabel="GetLabel">
<group id="Grp1" getLabel="GetLabel">
<dropDown id="DD1" getLabel="GetLabel" getImage="GetImage"
getItemCount="GetItemCount" getItemLabel="GetItemLabel"
getItemImage="GetItemImage" getSelectedItemIndex="GetSelectedItemIndex"
getItemScreentip="GetItemScreenTip" getItemSupertip="GetItemSuperTip"
onAction="MyDDMacro">
</dropDown>
<dropDown id="DD2" getLabel="GetLabel" getItemCount="GetItemCount"
getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
onAction="MyDDMacro">
</dropDown>
<dropDown id="DD3" getLabel="GetLabel" getItemCount="GetItemCount"
getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
onAction="MyDDMacro">
</dropDown>
<dropDown id="DD4" getLabel="GetLabel" getItemCount="GetItemCount"
getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
onAction="MyDDMacro">
</dropDown>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

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" <iDocs@docsliveonline.com> 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."
>
>
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>
> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
>
> <ribbon startFromScratch="false">
>
> <tabs>
>
> <tab id="Test" label="Test">
>
> <group id="iTest"
> label="iLabel">
>
> <button id="Btn1" label="2
> Spaces . ? ! Clean" size="large" image="image1" onAction="Doc_Clean"/>
>
> <button
> idMso="StylesModifyStyle" />
>
> <dropDown id="DD"
> label="M1" onAction="GetDDIndex" getItemCount= "GetDDCount"
> getItemLabel="GetDDLabels">
>
> </dropDown>
>
> <dropDown
> id="DD1" label="M2" onAction="GetDDIndex" getItemCount= "GetDDCount"
> getItemLabel="GetDDLabels">
>
> </dropDown>
>
>
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>
> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
>
> <ribbon startFromScratch="false">
>
> <tabs>
>
> <tab id="Test" label="Test">
>
> <group id="iTest"
> label="iLabel">
>
> <button id="Btn1" label="2
> Spaces . ? ! Clean" size="large" image="image1" onAction="Doc_Clean"/>
>
> <button
> idMso="StylesModifyStyle" />
>
> <dropDown id="DD"
> label="M1" onAction="GetDDIndex" getItemCount= "GetDDCount"
> getItemLabel="GetDDLabels">
>
> </dropDown>
>
> <dropDown
> id="DD1" label="M2" onAction="GetDDIndex" getItemCount= "GetDDCount"
> getItemLabel="GetDDLabels">
>
> </dropDown>
>
>
>
> Et cetera....
>
>
>
> Code Module which needs to be expanded on to include ALL the IDs for
> dropdowns and Cases for the macros - Am I being too simplistic expecting
> the macros to be sequential Macro1 to Macro50 and expecting to modify the
> DD Id?:
>
>
>
> Option Explicit
>
> Sub GetDDIndex(ByVal control As IRibbonControl, selectedID As String,
> _
> selectedIndex As Integer)
> Select Case selectedIndex
> Case 0
> Macros.Macro1
> Case 1
> Macros.Macro2
> Case 2
> Macros.Macro3
> Case 3
> Macros.Macro4
> Case 4
> Macros.Macro5
>
> Case 5
> Macros.Macro6
>
> Case 6
> Macros.Macro7
>
> End Select
> End Sub
>
> Sub GetDDCount(ByVal control As IRibbonControl, ByRef count)
> count = 7
> End Sub
>
> Sub GetDDLabels(ByVal control As IRibbonControl, _
> index As Integer, ByRef label)
> Dim i As Long
> For i = 0 To index
> label = Choose(i + 1, "Clear Text", _
> "Macro Clear FR", _
> "Macro 3", _
> "Macro 4", _
> "Macro 5", _
> "Macro 6", _
> "Macro 7")
> Next i
> End Sub
>
> Sub Doc_Clean(ByVal control As IRibbonControl)
> Macros.Doc_Clean
> End Sub
>
>
>
>
>
>



Re: Add Custom Tab Ribbon07 with Multiple DropDowns - Help! by Summer

Summer
Sat Mar 01 13:44:10 PST 2008

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" <gmaxey@mvps.oSCARrOMEOgOLF> 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.
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
> onLoad="Onload">
> <ribbon>
> <tabs>
> <tab id="CustomTab" getLabel="GetLabel">
> <group id="Grp1" getLabel="GetLabel">
> <dropDown id="DD1" getLabel="GetLabel" getImage="GetImage"
> getItemCount="GetItemCount" getItemLabel="GetItemLabel"
> getItemImage="GetItemImage" getSelectedItemIndex="GetSelectedItemIndex"
> getItemScreentip="GetItemScreenTip" getItemSupertip="GetItemSuperTip"
> onAction="MyDDMacro">
> </dropDown>
> <dropDown id="DD2" getLabel="GetLabel" getItemCount="GetItemCount"
> getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
> onAction="MyDDMacro">
> </dropDown>
> <dropDown id="DD3" getLabel="GetLabel" getItemCount="GetItemCount"
> getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
> onAction="MyDDMacro">
> </dropDown>
> <dropDown id="DD4" getLabel="GetLabel" getItemCount="GetItemCount"
> getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
> onAction="MyDDMacro">
> </dropDown>
> </group>
> </tab>
> </tabs>
> </ribbon>
> </customUI>
>
> 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" <iDocs@docsliveonline.com> 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."
>>
>>
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>
>> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
>>
>> <ribbon startFromScratch="false">
>>
>> <tabs>
>>
>> <tab id="Test" label="Test">
>>
>> <group id="iTest"
>> label="iLabel">
>>
>> <button id="Btn1" label="2
>> Spaces . ? ! Clean" size="large" image="image1" onAction="Doc_Clean"/>
>>
>> <button
>> idMso="StylesModifyStyle" />
>>
>> <dropDown id="DD"
>> label="M1" onAction="GetDDIndex" getItemCount= "GetDDCount"
>> getItemLabel="GetDDLabels">
>>
>> </dropDown>
>>
>> <dropDown
>> id="DD1" label="M2" onAction="GetDDIndex" getItemCount= "GetDDCount"
>> getItemLabel="GetDDLabels">
>>
>> </dropDown>
>>
>>
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>
>> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
>>
>> <ribbon startFromScratch="false">
>>
>> <tabs>
>>
>> <tab id="Test" label="Test">
>>
>> <group id="iTest"
>> label="iLabel">
>>
>> <button id="Btn1" label="2
>> Spaces . ? ! Clean" size="large" image="image1" onAction="Doc_Clean"/>
>>
>> <button
>> idMso="StylesModifyStyle" />
>>
>> <dropDown id="DD"
>> label="M1" onAction="GetDDIndex" getItemCount= "GetDDCount"
>> getItemLabel="GetDDLabels">
>>
>> </dropDown>
>>
>> <dropDown
>> id="DD1" label="M2" onAction="GetDDIndex" getItemCount= "GetDDCount"
>> getItemLabel="GetDDLabels">
>>
>> </dropDown>
>>
>>
>>
>> Et cetera....
>>
>>
>>
>> Code Module which needs to be expanded on to include ALL the IDs for
>> dropdowns and Cases for the macros - Am I being too simplistic expecting
>> the macros to be sequential Macro1 to Macro50 and expecting to modify
>> the DD Id?:
>>
>>
>>
>> Option Explicit
>>
>> Sub GetDDIndex(ByVal control As IRibbonControl, selectedID As String,
>> _
>> selectedIndex As Integer)
>> Select Case selectedIndex
>> Case 0
>> Macros.Macro1
>> Case 1
>> Macros.Macro2
>> Case 2
>> Macros.Macro3
>> Case 3
>> Macros.Macro4
>> Case 4
>> Macros.Macro5
>>
>> Case 5
>> Macros.Macro6
>>
>> Case 6
>> Macros.Macro7
>>
>> End Select
>> End Sub
>>
>> Sub GetDDCount(ByVal control As IRibbonControl, ByRef count)
>> count = 7
>> End Sub
>>
>> Sub GetDDLabels(ByVal control As IRibbonControl, _
>> index As Integer, ByRef label)
>> Dim i As Long
>> For i = 0 To index
>> label = Choose(i + 1, "Clear Text", _
>> "Macro Clear FR", _
>> "Macro 3", _
>> "Macro 4", _
>> "Macro 5", _
>> "Macro 6", _
>> "Macro 7")
>> Next i
>> End Sub
>>
>> Sub Doc_Clean(ByVal control As IRibbonControl)
>> Macros.Doc_Clean
>> End Sub
>>
>>
>>
>>
>>
>>
>
>



Re: Add Custom Tab Ribbon07 with Multiple DropDowns - Help! PLUS QAT by Summer

Summer
Sat Mar 01 19:03:56 PST 2008

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" <gmaxey@mvps.oSCARrOMEOgOLF> 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.
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
> onLoad="Onload">
> <ribbon>
> <tabs>
> <tab id="CustomTab" getLabel="GetLabel">
> <group id="Grp1" getLabel="GetLabel">
> <dropDown id="DD1" getLabel="GetLabel" getImage="GetImage"
> getItemCount="GetItemCount" getItemLabel="GetItemLabel"
> getItemImage="GetItemImage" getSelectedItemIndex="GetSelectedItemIndex"
> getItemScreentip="GetItemScreenTip" getItemSupertip="GetItemSuperTip"
> onAction="MyDDMacro">
> </dropDown>
> <dropDown id="DD2" getLabel="GetLabel" getItemCount="GetItemCount"
> getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
> onAction="MyDDMacro">
> </dropDown>
> <dropDown id="DD3" getLabel="GetLabel" getItemCount="GetItemCount"
> getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
> onAction="MyDDMacro">
> </dropDown>
> <dropDown id="DD4" getLabel="GetLabel" getItemCount="GetItemCount"
> getItemLabel="GetItemLabel" getSelectedItemIndex="GetSelectedItemIndex"
> onAction="MyDDMacro">
> </dropDown>
> </group>
> </tab>
> </tabs>
> </ribbon>
> </customUI>
>
> 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" <iDocs@docsliveonline.com> 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."
>>
>>
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>
>> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
>>
>> <ribbon startFromScratch="false">
>>
>> <tabs>
>>
>> <tab id="Test" label="Test">
>>
>> <group id="iTest"
>> label="iLabel">
>>
>> <button id="Btn1" label="2
>> Spaces . ? ! Clean" size="large" image="image1" onAction="Doc_Clean"/>
>>
>> <button
>> idMso="StylesModifyStyle" />
>>
>> <dropDown id="DD"
>> label="M1" onAction="GetDDIndex" getItemCount= "GetDDCount"
>> getItemLabel="GetDDLabels">
>>
>> </dropDown>
>>
>> <dropDown
>> id="DD1" label="M2" onAction="GetDDIndex" getItemCount= "GetDDCount"
>> getItemLabel="GetDDLabels">
>>
>> </dropDown>
>>
>>
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>
>> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
>>
>> <ribbon startFromScratch="false">
>>
>> <tabs>
>>
>> <tab id="Test" label="Test">
>>
>> <group id="iTest"
>> label="iLabel">
>>
>> <button id="Btn1" label="2
>> Spaces . ? ! Clean" size="large" image="image1" onAction="Doc_Clean"/>
>>
>> <button
>> idMso="StylesModifyStyle" />
>>
>> <dropDown id="DD"
>> label="M1" onAction="GetDDIndex" getItemCount= "GetDDCount"
>> getItemLabel="GetDDLabels">
>>
>> </dropDown>
>>
>> <dropDown
>> id="DD1" label="M2" onAction="GetDDIndex" getItemCount= "GetDDCount"
>> getItemLabel="GetDDLabels">
>>
>> </dropDown>
>>
>>
>>
>> Et cetera....
>>
>>
>>
>> Code Module which needs to be expanded on to include ALL the IDs for
>> dropdowns and Cases for the macros - Am I being too simplistic expecting
>> the macros to be sequential Macro1 to Macro50 and expecting to modify
>> the DD Id?:
>>
>>
>>
>> Option Explicit
>>
>> Sub GetDDIndex(ByVal control As IRibbonControl, selectedID As String,
>> _
>> selectedIndex As Integer)
>> Select Case selectedIndex
>> Case 0
>> Macros.Macro1
>> Case 1
>> Macros.Macro2
>> Case 2
>> Macros.Macro3
>> Case 3
>> Macros.Macro4
>> Case 4
>> Macros.Macro5
>>
>> Case 5
>> Macros.Macro6
>>
>> Case 6
>> Macros.Macro7
>>
>> End Select
>> End Sub
>>
>> Sub GetDDCount(ByVal control As IRibbonControl, ByRef count)
>> count = 7
>> End Sub
>>
>> Sub GetDDLabels(ByVal control As IRibbonControl, _
>> index As Integer, ByRef label)
>> Dim i As Long
>> For i = 0 To index
>> label = Choose(i + 1, "Clear Text", _
>> "Macro Clear FR", _
>> "Macro 3", _
>> "Macro 4", _
>> "Macro 5", _
>> "Macro 6", _
>> "Macro 7")
>> Next i
>> End Sub
>>
>> Sub Doc_Clean(ByVal control As IRibbonControl)
>> Macros.Doc_Clean
>> End Sub
>>
>>
>>
>>
>>
>>
>
>



Re: Add Custom Tab Ribbon07 with Multiple DropDowns - Help! PLUS QAT by Greg

Greg
Sat Mar 01 20:47:16 PST 2008

Summer,

I don't know what to tell you. Like you, I am just stumbling along t