• Executing Custom Ribbon Controls

    Author
    Topic
    #469620

    In Excel 2003 you could use VBA code similar to the following to simulate the push of a button on a customized command bar.

    Code:
    CommandBars("Command Bar Name").Controls("Control Name").Execute

    Is there a similar capability for an Excel 2007 COM Add-in that adds its own tab to the Excel 2007 ribbon?

    I don’t want to modify or change anything on the add-in, I just want the VBA code to execute the add-in’s controls.

    Thanks,

    Viewing 2 reply threads
    Author
    Replies
    • #1229051

      I’ve looked around for this, and couldn’t find it. Lots of code examples for adding controls, but didn’t see any for interrogating or manipulating the ones that are there. Someone may have discovered a way, but I wasn’t able to turn it up in a search.

    • #1229105

      In your VB6 project (assuming that is where you are building the COM addin in), you use code like this in the XLConnect designer:

      Code:
      Private Function IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As String
          IRibbonExtensibility_GetCustomUI = "" & _
                      "" & _
                          "" & _
                              "" & _
                                  "" & _
                                      "" & _
                                  "" & _
                              "" & _
                          "" & _
                      "" & _
                  ""
      End Function
      
      Public Function About(Control As Object)
          Dim fAbout As frmAbout
          Set fAbout = New frmAbout
          fAbout.Show vbModal
          Set fAbout = Nothing
      End Function
    • #1229303

      I think the answer is no, unless you can use SendKeys, since the ExecuteMso method only works for built-in controls, and I don’t know of another method of simulating a click on a ribbon control.

    Viewing 2 reply threads
    Reply To: Executing Custom Ribbon Controls

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: