以编程方式自定义 Office 功能区
我正在为 Office(2007 和 2010)编写一个插件,到目前为止,我已经使用 Fluent Ribbon XML 来自定义不同的功能区。
我现在使用这种方法遇到的问题是,我希望代码具有更大的灵活性,并且让不同的模块向功能区添加更多按钮,而不用在 XML 中对它们进行硬编码 - 插件由几个断开连接的模块组成,并且它并不确切地“知道”它可能需要哪些功能区元素。
有办法做到吗?我遇到了 LoadCustomUI 方法Application 对象,但它在 C# 中不可用。看起来正是我可能在我的场景中使用的。
I am writing an addin to Office (both 2007 and 2010), and have so far used the Fluent Ribbon XML to customize the different ribbons.
The problem I am having now with that approach, is that I want to have a bit more flexibility in my code, and have different modules add more buttons to the ribbon, without hard coding them in XML - The addin is composed of several disconnected modules, and it doesn't "know" exactly what ribbon elements it might need.
Is there a way to do it? I bumped into the LoadCustomUI method on the Application object, but it is not available in C#. Looks like just what I might have used for my scenario.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 .NET 4(我假设您因为面向 Office 2010 而使用它),您将重写
CreateRibbonExtensibilityObject
。可以在此页面上找到更多信息:功能区对象模型。这也是一本好书:在运行时更新功能区上的控件。For .NET 4 (which I assume you're using because of targetting Office 2010), you'll override
CreateRibbonExtensibilityObject
. More info can be found on this page: Ribbon Object Model. This is also a good read: Updating the Controls on a Ribbon at Run Time.