在Excel中选择VSTO自定义功能区

在Excel中选择VSTO自定义功能区

本文介绍了在Excel中选择VSTO自定义功能区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当VSTO代码在Excel 2007中创建列表对象并应用表格样式时,表格工具/设计"选项卡将自动激活.然后,当用户选择一个非表格单元格时,默认情况下将激活主页"选项卡.有没有办法抑制此行为或将活动选项卡重置为启动操作的自定义选项卡?我想让自定义功能区在创建表的操作之后可见.

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 cell, the Home tab is activated by default. Is there a way to either suppress this behavior or reset the active tab to the custom tab that started the action? What I would like is for the custom ribbon to be visible after the action that creates the table.

推荐答案

我在.

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.

如果将此选项与工作表SelectionChanged事件配对,则可以确保在更改所选单元格后将它们带回到适当的选项卡(不是TabHome).

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.

这篇关于在Excel中选择VSTO自定义功能区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 07:07