如何禁用的Excel内置RibbonButton? [英] How to disable Excel built-in RibbonButton?

查看:401
本文介绍了如何禁用的Excel内置RibbonButton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以设置一个Excel 2010中内置RibbonButton从为enabled = FALSE一个Excel VSTO加载

Is it possible to set an excel 2010 built in RibbonButton to enabled=false from an excel VSTO Add-In?

我试过如下:?

CommandBarControls controlls=Globals.ThisAddIn.Application.CommandBars.FindControls(MsoControlType.msoControlButton, 7374, null, false);
/// 7374 is the office control id of the control I want to access

foreach (CommandBarControl control in controlls)
{
    control.Enabled = false;
}



但这似乎只为右键上下文菜单的工作。而不是为区按钮。

But this seems to work only for the right click context menu. And not for the ribbon buttons.

推荐答案

可以,除非你使用的 startFromScratch 丝带UI属性。 参考请参阅MSDN。

You can only disable tabs, not controls unless you use the startFromScratch Ribbon UI attribute. See MSDN for reference.

另请参见良好的资源丝带XML FAQ 在Excel功能区操作。

Also see Ribbon XML FAQ for good resources on Excel Ribbon manipulation.

这篇关于如何禁用的Excel内置RibbonButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆