Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Activate Ribbon Tab In Excel 2007 2010 *

  1. #1
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10

    Activate Ribbon Tab In Excel 2007 2010 *

    One can access the Ribbon by using Commandbars("Ribbon") that will return an IAccessible object. You can access the tabs using the oleacc.dll library which can return an array of other IAccessible objects which are basically the list of all child elements. So the first child of the ribbon would be its tab. Using the IDs (which are strings) of these children objects you can filter in to the next child level which can be menu items etc.

    Credit to Tony Jollans, Microsoft Word MVP for the ribbon demo that you can find at www.WordArticles.com

    Here you can download a working example of how to activate a tab in either 2007 or 2010 versions of Excel. Note, for Excel 2010, MS has already incorporated the ActivateTab and ActivateTabMso methods, so one doesn't have to worry about elaborate codes to get the job done. The XML code used is given below

    PHP Code:
    <customUI onLoad="OLUIR" xmlns=http://schemas.microsoft.com/office/2006/01/customui>
    <ribbon
    <
    tabs>
    <
    tab id="tabAUniqueNameIDForMyNewTab" label="My New Tab" insertAfterMso="TabView">
    </
    tab>
    </
    tabs
    </
    ribbon
    </
    customUI
    Attached Files Attached Files
    Last edited by DocAElstein; 07-11-2023 at 11:57 AM.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    9
    Rep Power
    0

    I can't seem to make this work with the "Add-In" tab

    I was able to make this work on all the tabs except for the "Add-Ins" and this is the one I'm wanting to display. Is there something I have to do special for the "-" in 'Add-Ins'?

    Also I saw you mentioned 2010 had some built in functionality....If I am using 2010 then do I not need all of your code?

    Thanks.

    Phil


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=XQAIYCT4f8Q&lc=UgwTUdEgR4bdt6crKXF4AaABAg.9xmkXGSciKJ9xonTti2s Ix
    https://www.youtube.com/watch?v=XQAIYCT4f8Q&lc=UgwWw16qBFX39JCRRm54AaABAg.9xnskBhPnmb9xoq3mGxu _b
    https://www.youtube.com/watch?v=XQAIYCT4f8Q&lc=UgzgWvzV-kvC4TJ8O414AaABAg.9xnFzCj8HRM9xon1p2ImxO
    https://www.youtube.com/watch?v=XQAIYCT4f8Q&lc=UgybZfNJd3l4FokX3cV4AaABAg.9xm_ufqOILb9xooIlv5P LY
    https://www.youtube.com/watch?v=XQAIYCT4f8Q&lc=UgzgWvzV-kvC4TJ8O414AaABAg.9xnFzCj8HRM9y38bzbSqaG
    https://www.youtube.com/watch?v=XQAIYCT4f8Q&lc=UgyWm8nL7syjhiHtpBF4AaABAg.9xmt8i0IsEr9y3FT9Y9F eM
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg.9xhyRrsUUOM9xpn-GDkL3o
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNsaS3Lp1
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgR1EPUkhw
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNe_XC-jK
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNPOdiDuv
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgN7AC7wAc
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 12-14-2023 at 02:55 AM.

  3. #3
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Phil,

    Welcome to Excel Fox

    You can simply call the function like so

    Code:
    Sub OLUIR(ribbon As IRibbonUI)
    
        On Error Resume Next
        If Val(Application.Version) = 14 Then
            ribbon.ActivateTabMso "TabAddIns" ' For Excel 2010
        ElseIf Val(Application.Version) = 12 Then
            Application.OnTime Now(), "ActivateMyTab" 'For Excel 2007
        End If
    
    End Sub
    
    Sub ActivateMyTab()
    
        ActivateTab "Add-Ins"
        
    End Sub
    Last edited by DocAElstein; 07-11-2023 at 11:58 AM.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  4. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    The code above is written to take care of Excel 2010 also....

    However, if you were only using 2010, you wouldn't need the IF condition
    Code:
    Sub OLUIR(ribbon As IRibbonUI)
    
        On Error Resume Next
            ribbon.ActivateTab "TabAddIns" ' For Excel 2010
    
    End Sub
    Last edited by DocAElstein; 07-11-2023 at 11:58 AM.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  5. #5
    Junior Member
    Join Date
    Jan 2012
    Posts
    9
    Rep Power
    0
    So do I have to call that sub? I for the live of me can't make the code work you gave me for just 2010. Don't I have to pass in a ribbon?
    Last edited by DocAElstein; 07-11-2023 at 11:59 AM.

  6. #6
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Check the attachment...
    Attached Files Attached Files
    Last edited by DocAElstein; 07-11-2023 at 11:59 AM.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  7. #7
    Junior Member
    Join Date
    Jan 2012
    Posts
    9
    Rep Power
    0

    I still can't seem to make it work

    I've attached my sample project. It has a menu which shows on the add-ins tab. With your code, I can't seem to give focus to it. I'm sure I missing something easy.
    Attached Files Attached Files
    Last edited by DocAElstein; 07-11-2023 at 11:59 AM.

  8. #8
    Junior Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    This example does not work in Excel 2007

    Hello,

    How To Activate A New Ribbon Tab.xlsm
    This is the example that I tried in Excel 2007.

    You asked me to start a new thread but the button to do so is not available. According to manual I do not have the rights probably. I have registered.

    If you open the example it creates the custom tab but gets an error 91 because the ReturnElement has value Nothing and cannnot call its method. In my opinion this is caused because GetAccessible does not find the custom tab in the control tree.

    Can you look into this example in spite of the fact that I did not create a new Thread?

    Thanks

    Rob Kemper

  9. #9
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Rob, I tried in quite a few computers, and this is working without any error in all those computers.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  10. #10
    Junior Member
    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    Quote Originally Posted by Excel Fox View Post
    Rob, I tried in quite a few computers, and this is working without any error in all those computers.
    I can confirm that this example file does not work with excel 2007.
    The sub "ActivateTab" is not able to set "PageTabListClient".

    Regards
    Last edited by DocAElstein; 07-11-2023 at 12:00 PM.

Similar Threads

  1. Test copy Activate Ribbon Tab In Excel 2007 2010 *
    By Excel Fox in forum Test Area
    Replies: 16
    Last Post: 01-22-2019, 05:05 PM
  2. Replies: 1
    Last Post: 11-23-2013, 08:41 PM
  3. Ribbon DatePicker Calendar Control For Excel 2007-2010
    By Excel Fox in forum Excel Ribbon and Add-Ins
    Replies: 5
    Last Post: 10-12-2013, 11:23 AM
  4. Ribbon Calendar DatePicker Word 2007-2010
    By Excel Fox in forum Download Center
    Replies: 24
    Last Post: 09-23-2013, 09:07 AM
  5. How To Add A New Ribbon Tab In Excel
    By Excel Fox in forum Excel Ribbon and Add-Ins
    Replies: 0
    Last Post: 04-09-2011, 12:14 PM

Tags for this Thread

Posting Permissions

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