This has nothing directly to do with the ribbon. Your button that inserts
text has a callback that can run arbitrary VBA code - just make it insert a
comment instead ...
Selection.Comments.Add Selection.Range, "The Moon's a Balloon"
You can make the whole thing as sophisticated as you like - it just depends
how much effort you want to put into it. A lookup to another Word document
or an Excel table or a text file or registry entries or ... is certainly
possible. I don't know off the top of my head how to fill in a dropdown in
the ribbon but it must be possible - or your ribbon button could bring up a
userform from which a choice could be made or maintenance of the cross
reference list could be done or ... the world's your lobster.
> Alright, so here's what I'm looking at.
>
[quoted text clipped - 18 lines]
>
> Thanks!
On Feb 27, 2:22 pm, "Tony Jollans" <My forename at my surname dot com>
wrote:
> This has nothing directly to do with the ribbon. Your button that inserts
> text has a callback that can run arbitrary VBA code - just make it insert a
[quoted text clipped - 38 lines]
>
> - Show quoted text -
I am not sure that I understand you complete objective, but continuing
with what Tony suggested, you only need the XML to define the Tab, the
Group, and ID the dropdown. You need to have an OnAction macro
defined for the DropDown. The XML might look something like this:
<?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" label="My Tab">
<group id="SampleGroup" label="Sample Group">
<dropDown id="DD1" label="My DropDownBox" getItemCount=
"GetItemCount" getItemLabel="GetItemLabel" onAction="MyDDMacro">
</dropDown>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Then in the VBA project module you can define how many dropdown items
there needs to be, what their labels are, and what happens when each
one is clicked:
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 selectedIndex
Case Is = 0
Selection.Comments.Add Selection.Range, "The Moon's a Balloon"
Case Is = 1
Selection.Comments.Add Selection.Range, "Tony is a master of the
array"
Case Is = 2
Selection.Comments.Add Selection.Range, "NG courtesy cop need not
reply"
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 = "Moon comment"
Case Is = 1
label = "Tony Comment"
Case Is = 2
label = "Courtesy cop comment"
End Select
End Select
End Sub
Sub GetItemCount(ByVal control As IRibbonControl, ByRef count)
Select Case control.ID
Case "DD1"
count = 3
Case Else
'Do Nothing
End Select
End Sub