You keep saying that your script doesn't have all of the ribbon elements, and then you show us script with the elements in it.We are going round in circles.
You keep saying that your script doesn't have all of the ribbon elements, and then you show us script with the elements in it.We are going round in circles.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
xld, I think we are talking past each other. The line of xml script below makes visible the pulldown menu "Calculators". So, from your perspective, yes, everything is there to make the dynamic menu visible. That is true.
I am asking: where is the script for the content of that dynamic menu. That pulldown menu contains several buttons. Each of which call a particular calculation routine. There has to be somewhere script for these buttons.<dynamicMenu id="ABCMenu1" tag="0" getVisible="HaveFolderTag" getLabel="FolderByTag" image="icnFolderLarge" size="large" getContent="MenuContent"/>
Without seeing any code, the menu items are probably returned with this callback
getContent="MenuContent"
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
I think your addin's dynamic menus' getContent callback requires constructing a XML string on the fly
Here's a little example (all 4 menus are the same just 'cause I was lazy) but show how I constructed the XML
On the WS Menu, Col A is the menu item label, Col B is the image, and Col C is the OnAction callback to call
BTW, I probably 'borrowed' 90% from someone on the web, but don't remember who or where so apologies to the original source. I just wrapped it to fit my style
Option Explicit 'Callback for GetContent to return XML used to create dynamicMenu Sub GetContent(control As IRibbonControl, ByRef content) Dim sXML As String Dim rMenus As Range Dim i As Long Dim arrLabels() As String Dim arrImages() As String Dim arrProcedures() As String Set rMenus = Worksheets("Menu").Cells(1, 1).CurrentRegion ReDim arrLabels(0 To rMenus.Rows.Count - 1) ReDim arrImages(0 To rMenus.Cells.Count - 1) ReDim arrProcedures(0 To rMenus.Rows.Count - 1) 'these are all the same for demo For i = LBound(arrProcedures) To UBound(arrProcedures) arrLabels(i) = rMenus(i + 1, 1).Value arrImages(i) = rMenus(i + 1, 2).Value arrProcedures(i) = rMenus(i + 1, 3).Value Next i 'Open the XML string Select Case control.ID Case "mMenu1" content = XMLDynMenuEntry("mMenu1", arrLabels, arrImages, arrProcedures) Case "mMenu2" content = XMLDynMenuEntry("mMenu2", arrLabels, arrImages, arrProcedures) Case "mMenu3" content = XMLDynMenuEntry("mMenu3", arrLabels, arrImages, arrProcedures) Case "mMenu4" content = XMLDynMenuEntry("mMenu4", arrLabels, arrImages, arrProcedures) Case Else 'Do Nothing End Select End Sub Private Function XMLDynMenuEntry(sButton As String, aLabel As Variant, aImage As Variant, aProc As Variant) As String Dim sQ As String, s As String Dim i As Long sQ = Chr(34) s = "<menu xmlns=" s = s & sQ & "http://schemas.microsoft.com/office/2006/01/customui" & sQ s = s & " itemSize=" & sQ & "normal" & sQ & ">" & vbCrLf For i = LBound(aLabel) To UBound(aLabel) s = s & "<button" s = s & " id=" & sQ & sButton & (i + 1) & sQ s = s & " label=" & sQ + (aLabel(i)) + sQ s = s & " imageMso=" & sQ + (aImage(i)) + sQ s = s & " onAction=" & sQ & (aProc(i)) & sQ s = s & "/>" & vbCrLf Next i s = s & "</menu>" XMLDynMenuEntry = s End Function
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Paul, great. Thank you. I got the concept. Again, I will keep your script as a template in case I need it.
I learned quite a bit in this thread!