Select VSTO Custom Ribbon in Excel

前端 未结 4 1406
野趣味
野趣味 2020-12-11 11:02

When VSTO code creates a list object and applies a table style in Excel 2007, the Table Tools/Design tab is activated automatically. When the user then selects a non-table

4条回答
  •  甜味超标
    2020-12-11 11:27

    I provided this same answer in another post as well.

    In VSTO2010, the ability to programmatically switch the selected tab was added. Norm Estabrook blogged about it.

    this.RibbonUI.ActivateTabMso("TabAddIns");
    

    So while there isn't an event that can be latched onto, at least you can switch the selected tab. For instance, I'm going to use the sheet selection event; when users switch between different sheets of my workbook, I am going to change their selected tab. Each sheet will correspond to a different ribbon tab.

    If you pair this with a sheet SelectionChanged event, you could ensure that they are taken back to the appropriate tab (not TabHome) after they change their selected cell.

提交回复
热议问题