Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 25

Thread: How does one activate ribbon components from an xlam file ?

  1. #1
    VBAX Regular
    Joined
    May 2010
    Posts
    65
    Location

    How does one activate ribbon components from an xlam file ?

    I came across an Excel add-in (.xlam) that appears to use VBA script to activate Ribbon groups. I would like to know how this is done.

    Illustrated in more detail but simplified. The xlam file creates a new Ribbon tab with one Ribbon group containing one button.
    If I click on this button additional ribbon groups are added to the Ribbon tab.

    A look in the VBA Editor VBA project list shows that no file was opened by clicking the Ribbon button.
    The Ribbon xml file of this xlam only contains the script for the one Ribbon tab, Ribbon group and button.

    I have the impression that the script activated by the button calls in the additional Ribbon groups and buttons.
    And this seems to work without opening another xlam file. I have no idea how that is done.

    Can somebody explain to me how to do that?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    You cannot add to the ribbon on the fly using VBA, so I would guess that the other groups and buttons are setup in the xlam but not visible, and when the button is clicked their visible property is set and the ribbon is invalidated.
    ____________________________________________
    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

  3. #3
    VBAX Regular
    Joined
    May 2010
    Posts
    65
    Location
    The ribbon xml file of the add-in has a comment at the top that says: <!-- The first part of the ribbon tab -->
    And as I said earlier. This xml file does not contain the script for the 2 button groups which appear after clicking the button.
    I know about visible and invisible. But that has not been used in this case.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Then I guess I do not know. What addin is it? Is it a COM addin created in VS?
    ____________________________________________
    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

  5. #5
    VBAX Regular
    Joined
    May 2010
    Posts
    65
    Location
    xlam

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Quote Originally Posted by dschmitt View Post
    I came across an Excel add-in (.xlam) that appears to use VBA script to activate Ribbon groups. I would like to know how this is done.

    Illustrated in more detail but simplified. The xlam file creates a new Ribbon tab with one Ribbon group containing one button.
    If I click on this button additional ribbon groups are added to the Ribbon tab.

    A look in the VBA Editor VBA project list shows that no file was opened by clicking the Ribbon button.
    The Ribbon xml file of this xlam only contains the script for the one Ribbon tab, Ribbon group and button.

    I have the impression that the script activated by the button calls in the additional Ribbon groups and buttons.
    And this seems to work without opening another xlam file. I have no idea how that is done.

    Can somebody explain to me how to do that?
    I believe that the XLAM has the Fluent XML in it for all the groups, but with only one Group visible; the other groups are also there but Not visible. It doesn't really 'create' a new tab, but has one itself

    Clicking the button changes a status variable and then Invalidates the ribbon.

    The getVisible callback for the groups then makes the second etc. groups visible

    I can make up a small example if your want.
    ---------------------------------------------------------------------------------------------------------------------

    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

  7. #7
    VBAX Regular
    Joined
    May 2010
    Posts
    65
    Location
    Paul, if you could give me an example that would be great. I have programmed quite a few Ribbon (xml) files. That is for all the add-ins I created for myself and at work. But these Ribbon files are relative simple. I just created tabs with button groups, pull down menus and checkboxes. I never used visible/invisible. But having said that, it is easy for me to understand the concept of visible/invisible. I read online and saw some example scripts.

    Based on what I learned online I looked in the ribbon xml file in question and looked for visible/invisible code and especially for the 2 "missing" pulldown menus and their buttons. My current understanding is that the code for the 2 pulldown menus with their buttons and onaction specifications must be there including a statement for visible/invisible. But that code is not there.

    Perhaps I don't understand enough yet, therefore I would appreciate, if you could provide me with an example that I could test to get a better understanding of the code.

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    This is in the attached XLSM, but I saved it as an XLAM and it seems to work OK


    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad" >
    <ribbon>
    <tabs>
    <tab id="CustomTab" label="My Tab">
      <group id="gMaster" label="Master Group">
      <toggleButton id="tbA"
       size="large"
       imageMso="A"
       getLabel="getToggleLabel"
       getPressed="getTogglePressed"
       onAction="onToggleAction"
       screentip = "This hides or shows Group A"
       />
      <toggleButton id="tbB"
       size="large"
       imageMso="B"
       getLabel="getToggleLabel"
       getPressed="getTogglePressed"
       onAction="onToggleAction"
       screentip = "This hides or shows Group B"
       />
      <toggleButton id="tbC"
       size="large"
       imageMso="C"
       getLabel="getToggleLabel"
       getPressed="getTogglePressed"
       onAction="onToggleAction"
       screentip = "This hides or shows Group C"
       />
     </group>
        
     <group id="gA" label="Group A" getVisible = "getGroupVisible">
      <button id="bA1" label="FirstA" size="large" onAction="actionButton" imageMso="HappyFace"/>
      <button id="bA2" label="SecondA" size="large" onAction="actionButton" imageMso="HappyFace" />
      <button id="bA3" label="ThirdA" size="large" onAction="actionButton" imageMso="HappyFace" />
     </group >
     <group id="gB" label="Group B"  getVisible = "getGroupVisible">
      <button id="bB1" label="FirstB" size="large" onAction="actionButton"  imageMso="HappyFace"/>
      <button id="bB2" label="SecondB" size="large" onAction="actionButton"  imageMso="HappyFace"/>
      <button id="bB3" label="ThirdB" size="large" onAction="actionButton"  imageMso="HappyFace"/>
     </group >
     <group id="gC" label="Group C"  getVisible = "getGroupVisible">
      <button id="bC1" label="FirstC" size="large" onAction="actionButton"  imageMso="HappyFace"/>
      <button id="bC2" label="SecondC" size="large" onAction="actionButton"  imageMso="HappyFace"/>
      <button id="bC3" label="ThirdC" size="large" onAction="actionButton"  imageMso="HappyFace"/>
     </group >
    </tab>
    </tabs>
    </ribbon>
    </customUI>


    and

    Option Explicit
    Public bVisibleA As Boolean, bVisibleB As Boolean, bVisibleC As Boolean
    Public bPressedA As Boolean, bPressedB As Boolean, bPressedC As Boolean
    Public oRibbon As IRibbonUI
     
    'Callback for customUI.onLoad
    Sub OnRibbonLoad(ribbon As IRibbonUI)
        Set oRibbon = ribbon
        
        bVisibleA = False
        bVisibleB = False
        bVisibleC = False
        bPressedA = False
        bPressedB = False
        bPressedC = False
     
    End Sub
    'Callback for tbA getLabel
    Sub getToggleLabel(control As IRibbonControl, ByRef returnedVal)
        Select Case control.ID
            Case "tbA"
                If bVisibleA Then
                    returnedVal = "Hide A"
                Else
                    returnedVal = "Show A"
                End If
            Case "tbB"
                If bVisibleB Then
                    returnedVal = "Hide B"
                Else
                    returnedVal = "Show B"
                End If
            Case "tbC"
                If bVisibleC Then
                    returnedVal = "Hide C"
                Else
                    returnedVal = "Show C"
                End If
        End Select
    End Sub
    'Callback for tbA getPressed
    Sub getTogglePressed(control As IRibbonControl, ByRef returnedVal)
        Select Case control.ID
            Case "tbA"
                returnedVal = bPressedA
            Case "tbB"
                returnedVal = bPressedB
            Case "tbC"
                returnedVal = bPressedC
        End Select
    End Sub
    'Callback for tbA onAction
    Sub onToggleAction(control As IRibbonControl, pressed As Boolean)
        
        Select Case control.ID
            Case "tbA"
                bPressedA = Not bPressedA
                bVisibleA = Not bVisibleA
                oRibbon.Invalidate
            Case "tbB"
                bPressedB = Not bPressedB
                bVisibleB = Not bVisibleB
                oRibbon.Invalidate
            Case "tbC"
                bPressedC = Not bPressedC
                bVisibleC = Not bVisibleC
                oRibbon.Invalidate
        End Select
    End Sub
    'Callback for gA getVisible
    Sub getGroupVisible(control As IRibbonControl, ByRef returnedVal)
        Select Case control.ID
            Case "gA"
                returnedVal = bVisibleA
            Case "gB"
                returnedVal = bVisibleB
            Case "gC"
                returnedVal = bVisibleC
        End Select
    End Sub
    'Callback for bA1 onAction
    Sub actionButton(control As IRibbonControl)
        MsgBox "You clicked " & control.ID
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    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

  9. #9
    VBAX Regular
    Joined
    May 2010
    Posts
    65
    Location
    Paul, very nice example! I understand how the scripts work. I will definitely keep this example as a template for my future work.
    Regarding my question, your xml script confirmed that the groups whose visibility toggle need to be marked with a getVisible statement in the xml file.
    And, importantly, the scripts for those visibility toggling ribbon elements are in the xml file. But in the xml file in question I don't see the script for these visibility toggling ribbon elements.
    I am now at home and it is weekend. I don't have the xml script with me. So, I can't show it to you now. I will get back to you early next week.

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Paul's suggestion is exactly the same as the one I made, but I referred to buttons not togglebuttons (and I made a demo with such). I didn't bother showing you my code because you said you knew that approach.

    But as you said, your addin doesn't have those hidden controls, which is why I asked what addin it was. Showing us the XML is pointless unless we can see the addin and its code as well.
    ____________________________________________
    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

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    BTW, just for info, this is the code I created

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"
              onLoad="rxDemoRibbonOnLoad"> 
    
        <ribbon>
            <tabs>
                <tab id="tabDemo" label="Demo Ribbon">
    
                    <group id="grpDemoGroup1" 
                           label="Initial Group" 
                           visible="true">
    
                        <button id="btnDemoShowRest"
                                onAction="rxDemoShowRest" 
                                label="Show Rest"  
                                imageMso="FileWorkflowTasks"
                                size="large"
                                visible="true"
                                enabled="true" />
                    </group>
    
                    <group id="grpDemoGroup2" 
                           label="Now You See Me" 
                           getVisible="rxDemoGetVisible">
    
                        <button id="btnDemoButton1"
                                onAction="rxDemoButton1" 
                                label="New Button 1"  
                                imageMso="ReviewProtectWorkbook"
                                size="large"
                                visible="true"
                                enabled="true" />
    
                        <button id="btnDemoButton2"
                                onAction="rxDemoButton2" 
                                label="New Button 2"  
                                imageMso="StartTimer"
                                size="large"
                                visible="true"
                                enabled="true" />
    
                        <button id="btnDemoButton3"
                                onAction="rxDemoButton3" 
                                label="New Button 3"  
                                imageMso="FileSaveAsPowerPointPpsx"
                                size="large"
                                visible="true"
                                enabled="true" />
                    </group>
                </tab> 
            </tabs>
        </ribbon>
    </customUI>
    Private Sub Workbook_Open()
        flgShowRest = False
    End Sub
    Global flgShowRest As Boolean
    Global rxDemoIRibbonUI As IRibbonUI
    
    Public Function rxDemoRibbonOnLoad(ribbon As IRibbonUI)
    
        Set rxDemoIRibbonUI = ribbon
            
        If Val(Application.Version) >= 14 Then rxDemoIRibbonUI.ActivateTab "tabDemo"
    End Function
    
    Public Function rxDemoGetVisible(control As IRibbonControl, ByRef Visible)
        
        Select Case control.ID
            
            Case "grpDemoGroup2":                   Visible = flgShowRest
        End Select
    End Function
    
    Public Function rxDemoShowRest(control As IRibbonControl)
        flgShowRest = Not flgShowRest
        rxDemoIRibbonUI.Invalidate
    End Function
    Attached Files Attached Files
    ____________________________________________
    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

  12. #12
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    @XLD --

    I had done something earlier with toggle buttons and the on/off feedback to the user seemed to be a little more better than buttons. So that's why I threw it in that way



    @dschmitt

    1. When you click one of the toggle buttons this fires which flips the status variables AND invalidates the ribbon ( = re-init status, etc.)

    Sub onToggleAction(control As IRibbonControl, pressed As Boolean)
        
        Select Case control.ID
            Case "tbA"
                bPressedA = Not bPressedA
                bVisibleA = Not bVisibleA
                oRibbon.Invalidate
            Case "tbB"
                bPressedB = Not bPressedB
                bVisibleB = Not bVisibleB
                oRibbon.Invalidate
            Case "tbC"
                bPressedC = Not bPressedC
                bVisibleC = Not bVisibleC
                oRibbon.Invalidate
        End Select
    End Sub
    [/CODE]


    2. As part of the ribbon re-initing, the 3 group getVisible callbacks each ask if the the group is to be displayed or not

    'Callback for gA getVisible
    Sub getGroupVisible(control As IRibbonControl, ByRef returnedVal)
        Select Case control.ID
            Case "gA"
                returnedVal = bVisibleA
            Case "gB"
                returnedVal = bVisibleB
            Case "gC"
                returnedVal = bVisibleC
        End Select
    End Sub
    There are many ways to clean the Mark I version code, but I went for a straight forward approach and didn't try to be too clever since that's when I get myself in trouble
    ---------------------------------------------------------------------------------------------------------------------

    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

  13. #13
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    @xld -- nice example. I forgot about ActivateTab


    This is the callback module a little more cleaned up

    One thing I REALLY don't like (philosophically) is having to use global variables to track status, but I've never found a way to avoid them


    Option Explicit
    Public bPressedA As Boolean, bPressedB As Boolean, bPressedC As Boolean
    Public oRibbon As IRibbonUI
    
    'Callback for customUI.onLoad
    Sub OnRibbonLoad(ribbon As IRibbonUI)
        Set oRibbon = ribbon
    End Sub
    'Callback for tbA getLabel
    Sub getToggleLabel(control As IRibbonControl, ByRef returnedVal)
        Select Case control.ID
            Case "tbA"
                returnedVal = IIf(bPressedA, "Hide A", "Show A")
            Case "tbB"
                returnedVal = IIf(bPressedB, "Hide B", "Show B")
            Case "tbC"
                returnedVal = IIf(bPressedC, "Hide C", "Show C")
        End Select
    End Sub
    'Callback for tbA getPressed
    Sub getTogglePressed(control As IRibbonControl, ByRef returnedVal)
        Select Case control.ID
            Case "tbA"
                returnedVal = bPressedA
            Case "tbB"
                returnedVal = bPressedB
            Case "tbC"
                returnedVal = bPressedC
        End Select
    End Sub
    'Callback for tbA onAction
    Sub onToggleAction(control As IRibbonControl, pressed As Boolean)
        Select Case control.ID
            Case "tbA"
                bPressedA = pressed
                oRibbon.Invalidate
            Case "tbB"
                bPressedB = pressed
                oRibbon.Invalidate
            Case "tbC"
                bPressedC = pressed
                oRibbon.Invalidate
        End Select
    End Sub
    'Callback for gA getVisible
    Sub getGroupVisible(control As IRibbonControl, ByRef returnedVal)
        Select Case control.ID
            Case "gA"
                returnedVal = bPressedA
            Case "gB"
                returnedVal = bPressedB
            Case "gC"
                returnedVal = bPressedC
        End Select
    End Sub
    'Callback for bA1 onAction
    Sub actionButton(control As IRibbonControl)
        MsgBox "You clicked Button = " & control.ID
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    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

  14. #14
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Quote Originally Posted by Paul_Hossler View Post
    I had done something earlier with toggle buttons and the on/off feedback to the user seemed to be a little more better than buttons. So that's why I threw it in that way
    Wasn't knocking it Paul, just remarking on what I used. I must admit ToggleButtons never come to mind for me for some reason.

    Quote Originally Posted by Paul_Hossler View Post
    One thing I REALLY don't like (philosophically) is having to use global variables to track status, but I've never found a way to avoid them
    You could maybe try a static variable, although that of course restricts you to amending it from just one place (or create a globals class ).
    ____________________________________________
    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

  15. #15
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Quote Originally Posted by xld View Post
    Wasn't knocking it Paul, just remarking on what I used. I must admit ToggleButtons never come to mind for me for some reason..
    Didn't take it that way.

    OP said Buttons in #1, but what fun would that be

    I (out of habit) use ToggleButtons and change the Label and sometimes the icon for things like hide/show
    ---------------------------------------------------------------------------------------------------------------------

    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

  16. #16
    VBAX Regular
    Joined
    May 2010
    Posts
    65
    Location
    I can't give you the xlam ribbon script because access to the script is locked. But, I think, a look at the screenshots of the ribbon and a look at the xml file should be sufficient to illustrate to you what I was trying to explain.

    I took screenshots of the Ribbon tab before and after clicking the "Connect" button (see attached jpg file).
    Clicking the "Connect" button starts the login procedure. With successful login the pulldown menus "Calculator" and "Finder" appear in the "Protocols" button groups.

    Below is the xml script. The key button group to look at is, I believe, the "Protocols" button group. To make the xml script shorter I removed 4 lines of dynamic menus in the "Protocols" button group.
    Question, where in the button group "Protocols" is the script for the pulldown menus "Calculator" and "Finder"?

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad"><ribbon>
    <tabs>
    
    
    <!-- The first half of the ribbon tab -->
    
    
    <tab id="ABCTab" getLabel="DisplayName" insertAfterMso="TabHome" getVisible="IsActive">
    
    
    <group id="ServerGroup" label="Server">
    
    
                   <splitButton id="ConnectSB" showLabel="true" size="large">
    
    
                                  <button id="ConnectABC” imageMso="ServerConnection" onAction="ConnectToServer" label="Connect"/>
    
                                  <menu id="ConnectMenu" enabled="true" label="Connection">
                                                   <button id="Connect" imageMso="ServerConnection" onAction="ConnectToServer" label="Connect to Server" getSupertip="ConnectToServerTip"/>
                                                   <button id="ChangeServer" image="icnChangeServer" onAction="ChangeServer" label="Change Server" getSupertip="ChangeServerTip"/>
                                  </menu>
    
    
                   </splitButton>
    
    
    </group>
    
    
    <group id="Menus" label="Protocols">
    
    
                  <dynamicMenu id="MenuABC” getEnabled="HaveABCProtocols" label="Recently Used" screentip="Recently used protocols" image="icnFolderLarge" size="large" getContent="ABCMenuContent"/>
    
                  <dynamicMenu id="Menu1" tag="0" getVisible="HaveFolderTag" getLabel="FolderTag" getSupertip="FolderTipTag" image="icnFolderLarge" size="large" getContent="MenuContentTag"/>
                  <dynamicMenu id="Menu2" tag="1" getVisible="HaveFolderTag" getLabel="FolderTag" getSupertip="FolderTipTag" image="icnFolderLarge" size="large" getContent="MenuContentTag"/>
    
                  <button id="OpenProtocolSearch" image="icnProtocolSearchLarge" size="large" onAction="OpenProtocolSearch" label="Protocol Search" getEnabled="HaveServerConnection"/>
    
    
    </group>
    
    
    <group id="ABProtocols" label=“Favorites">
    
    
                  <button id="OpenManageFavorites" getEnabled="HaveServerConnection" imageMso="AddToFavorites" onAction="OpenManageFavorites" label="Manage Favorites"/>
    
                  <button id="ABProtocol1" image="icnProtocol" onAction="RunABProtocolTag" tag="0" getVisible="HaveABProtocolTag" getLabel="ABProtocolNameTag" getSupertip="ABProtocolCommentTag"/>
                  <button id="ABProtocol2" image="icnProtocol" onAction="RunABProtocolTag" tag="1" getVisible="HaveABProtocolTag" getLabel="ABProtocolNameTag" getSupertip="ABProtocolCommentTag"/>
    
    
                  <dynamicMenu id="ABMoreMenu" tag="6" getVisible="HaveMoreABProtocols" label="More" image="icnFolder" getContent="ABMenuContent"/>
    
    
    </group>
    
    
    </tab>
    </tabs>
    </ribbon>
    </customUI>
    Attached Images Attached Images

  17. #17
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    As we said, you have the controls just not visible. They are menus not buttons, but they both have the getLabel callback that sets the name. There be no dragons there.
    ____________________________________________
    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

  18. #18
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Question, where in the button group "Protocols" is the script for the pulldown menus "Calculator" and "Finder"?


    <dynamicMenu id="Menu1" tag="0" getVisible="HaveFolderTag" getLabel="FolderTag" getSupertip="FolderTipTag" image="icnFolderLarge" size="large" getContent="MenuContentTag"/>
    <dynamicMenu id="Menu2" tag="1" getVisible="HaveFolderTag" getLabel="FolderTag" getSupertip="FolderTipTag" image="icnFolderLarge" size="large" getContent="MenuContentTag"/>

    It appears that there is a 'HaveFolderTag' callback in the locked XLAM that determines if the menu is visible or not. The getVisible callback works just like the ones we've shown in the examples

    Edit the XML to just delete the getVisible="HaveFolderTag", save it and see. The two missing ones will most likely be there all the time (or at least that's my guess)
    ---------------------------------------------------------------------------------------------------------------------

    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

  19. #19
    VBAX Regular
    Joined
    May 2010
    Posts
    65
    Location
    I boiled down the xml script to the bare bones. The script below just has the login button and the 2 dynamic getVisible menus. I tested it. It is functional.
    Paul, in your example all the ribbon elements are in the xml file and you use the xlam script to control the visible/invisible toggle.
    In my example the xml does not contain all the ribbon elements. That means the xlam script does not only control the toggle but also contains the script for the to be toggled ribbon elements.
    Can you give me a simple xml/xlam script example with one toggling dynamic menu that reproduces my example?

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="RibbonLoad">
    <ribbon> 
    <tabs>
    
    <tab id="ABCTab"  getLabel="RibbonDisplayName" insertAfterMso="TabHome" getVisible="RibbonIsActive">
                    
    <group id="ABCServerGroup" label="Server">
                                            
        <button id="ABCConnect" imageMso="ServerConnection"  onAction="ConnectToServer"  label="Connect"/>            
    
    </group>
                    
    <group id="ABCMenus"  label="Protocols">
                
        <dynamicMenu id="ABCMenu1"  tag="0" getVisible="HaveFolderTag"  getLabel="FolderByTag" image="icnFolderLarge" size="large"  getContent="MenuContent"/>        
        <dynamicMenu id="ABCMenu2"  tag="1" getVisible="HaveFolderTag"  getLabel="FolderByTag"  image="icnFolderLarge"  size="large"  getContent="MenuContent"/>
            
    </group>
                
    </tab>        
    </tabs>
    </ribbon>
    </customUI>
    Last edited by dschmitt; 01-19-2015 at 07:37 PM.

  20. #20
    VBAX Regular
    Joined
    May 2010
    Posts
    65
    Location
    Paul, if you are creating an example, please populate the getVisible dynamic menu with a couple buttons that activate a simple script like the Msgbox window in your example.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •