none
Command bars in Excel 2007 Add-in Tab

    Question

  • I wrote a VSTO solution for Excel 2003 several years ago using the VSTO 2005 v2 runtime which includes a command bar. I now have some users who are using it with Excel 2007. While I realize this is not officially supported, everything seems to work. However there is an annoyance with the command bar. The user has to constantly click on the Add-in Tab to access the custom command bar. After every command, the "Design" tab becomes active automatically. If the user wants to click on another command, he must click on the Add-in Tab to gain access to the custom command bar.

    Most of the commands involves the VSTO worksheet to be updated. Is it this update that is causing the ribbon to default back to the Design tab? Is there a way for me to keep the focus on the Add-In Tab so that my custom command bar stays in view?
    Friday, January 15, 2010 5:32 AM

Answers

  • Hello Julie,

    Welcome to MSDN Forums!

    If code include some steps to insert a table into the worksheet, the behavior may be some different with Excel 2003, the Design tab will be activated if your code selectd any cells inside the Table after insert.

    This VBA code could demonstrate how this issue comes:
    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
        ActiveSheet.ListObjects.Add(xlSrcRange, Range("$C$9"), , xlNo).Name = "Table1"
        Range("Table1[[#All],[Column1]]").Select
    End Sub

    If remove the last line of above code, we'll be able to avoid the issue. The situation is exactly same in VSTO.

    If you need to programmatically move the foucs on to the Add-In Tab, it will be a long story to tell. you could refer to this earlier thread:
    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/72253440-09f1-451d-8e2a-8cd7d3efa13f/

    Hope this could help.

    Thanks.
     

    Tim Li

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Julie2 Tuesday, January 19, 2010 5:54 PM
    Friday, January 15, 2010 9:17 AM

All replies

  • Hi Julie

    First of all, no, there's no (simple, reliable) way for you to keep the focus on the Add-in tab. The Ribbon for 2007 doesn't provide anyway to select a particular tab or force a Tab to keep the focus, although there are workarounds (SendKeys, or using the Ribbon's Accessibility interface - but not if you're solution bases on the 2003 libraries).

    The user could access the Ribbon perhaps more quickly using the keyboard shortcut (press Alt, then the letter next to the add-ins Tab).

    The "Design" tab is something that's not part of the Excel Ribbon in "default mode". There are built-in "Design" tabs that will come up when certain kinds of things are selected on the worksheet, such as graphical objects or Charts. There's usually a descriptive label above the Tab about the type of "Design" that will give information about what this is for. See if the user has selected something like that, then ask him to click in a "plain cell" to see if that makes any difference on the Tab that is in front.

    Since this is a custom workbook, the best approach would be to put these buttons in an Actions Pane, rather than in a Toolbar (or in both). Then it won't matter what Tab is displayed in the Ribbon.
    Cindy Meister, VSTO/Word MVP
    Friday, January 15, 2010 7:59 AM
  • Hello Julie,

    Welcome to MSDN Forums!

    If code include some steps to insert a table into the worksheet, the behavior may be some different with Excel 2003, the Design tab will be activated if your code selectd any cells inside the Table after insert.

    This VBA code could demonstrate how this issue comes:
    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
        ActiveSheet.ListObjects.Add(xlSrcRange, Range("$C$9"), , xlNo).Name = "Table1"
        Range("Table1[[#All],[Column1]]").Select
    End Sub

    If remove the last line of above code, we'll be able to avoid the issue. The situation is exactly same in VSTO.

    If you need to programmatically move the foucs on to the Add-In Tab, it will be a long story to tell. you could refer to this earlier thread:
    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/72253440-09f1-451d-8e2a-8cd7d3efa13f/

    Hope this could help.

    Thanks.
     

    Tim Li

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Julie2 Tuesday, January 19, 2010 5:54 PM
    Friday, January 15, 2010 9:17 AM
  • Hi, 

     


    I am writing to check the status of the issue on your side. Could you please let me know if the suggestion works for you or not? If you have any questions or concerns, please feel free to let me know. I will be more than happy to be of assistance.


    Tim Li

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, January 19, 2010 1:52 AM
  • Yes this worked. I have data in an Excel List in the VSTO worksheet. When the user initiates and action, the List in the worksheet is updated and the focus (selected range) is in the list. I explicitly set the selection to a cell outside of the List and that seems to work. Thanks.

    Tuesday, January 19, 2010 5:57 PM