简体   繁体   English

VSTO 为 Outlook 功能区创建命令而不通过加载项代码添加到功能区?

[英]VSTO Create command for Outlook ribbon without adding to ribbon via add-in code?

So super new at Outlook add-in's but I have created a VSTO add-in in C# for Outlook that is working.在 Outlook 插件中非常新,但我在 C# 中为 Outlook 创建了一个 VSTO 插件,该插件正在工作。 The function it does is triggered by a button on the ribbon which is added to the Add-Ins section on startup.它所做的 function 由功能区上的按钮触发,该按钮在启动时添加到加载项部分。 I would prefer this not be added automatically by the add-in as it is now and instead be a command the user would add through the customize ribbon action in Outlook.我希望它不会像现在一样由加载项自动添加,而是用户将通过 Outlook 中的自定义功能区操作添加的命令。 I can use the customize ribbon function in Outlook to add this command to other ribbons and groups but so far have not figured out how to not add it to a ribbon through the add-in code and still have it available to customize.我可以使用 Outlook 中的自定义功能区 function 将此命令添加到其他功能区和组,但到目前为止还没有弄清楚如何不通过加载项代码将其添加到功能区并且仍然可以自定义。

Currently the button is created via XML not the ribbon designer.目前该按钮是通过 XML 而不是功能区设计器创建的。 I have not included any code here since I'm not sure that any is needed for this question or what it would be if so.我没有在这里包含任何代码,因为我不确定这个问题是否需要任何代码,或者如果需要的话会是什么。

Try to add visible="false" attribute to the button.尝试将visible="false"属性添加到按钮。

Instead of hard-coding the visible attribute set to false you may consider using ribbon callbacks where you could set the visibility of your ribbon controls at runtime dynamically.您可以考虑使用功能区回调,而不是将visible属性硬编码为 false,您可以在其中动态设置功能区控件在运行时的可见性。 So, you could keep settings for displaying ribbon controls depending on the user's preferences.因此,您可以根据用户的偏好保留显示功能区控件的设置。 The getVisible callback has the following signature (depending on your programming language): getVisible回调具有以下签名(取决于您的编程语言):

C#: bool GetVisible(IRibbonControl control)

VBA: Sub GetVisible(control As IRibbonControl, ByRef visible)

C++: HRESULT GetVisible([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarfVisible)

Visual Basic: Function GetVisible(control As IRibbonControl) As Boolean

So, you just need to return an appropriate boolean value whether to display controls or not.因此,无论是否显示控件,您只需要返回一个适当的 boolean 值即可。

The IRibbonUI.Invalidate or IRibbonUI.InvalidateControl methods can help you update the ribbon controls at runtime (get your callbacks invoked and get updated values). IRibbonUI.InvalidateIRibbonUI.InvalidateControl方法可以帮助您在运行时更新功能区控件(调用您的回调并获取更新的值)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM