Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    USA
    Posts
    122
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    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,

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    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.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 = "<customUI xmlns=""http://schemas.microsoft.com/office/2006/01/customui"">" & _
                    "<ribbon>" & _
                        "<tabs>" & _
                            "<tab idMso=""TabHome"">" & _
                                "<group id=""XLRef"" label=""Demo"">" & _
                                    "<button id=""btnAbout"" imageMso=""Info"" label=""About"" size=""normal"" onAction=""About"" />" & _
                                "</group>" & _
                            "</tab>" & _
                        "</tabs>" & _
                    "</ribbon>" & _
                "</customUI>"
    End Function
    
    Public Function About(Control As Object)
        Dim fAbout As frmAbout
        Set fAbout = New frmAbout
        fAbout.Show vbModal
        Set fAbout = Nothing
    End Function
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,895
    Thanks
    0
    Thanked 85 Times in 81 Posts
    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.
    Regards,
    Rory
    Microsoft MVP - Excel.

Posting Permissions

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