excel - 如何在 customUI 功能区中显示版本号
问题描述
我有一个 Excel VBA 项目,我希望在其中发布更新。它有一个自定义 UI 功能区。出于支持目的(屏幕截图),我想在功能区中显示应用程序的版本号,这将从隐藏的工作表中读取。我希望只用一个标签控件来做到这一点。但是标签控件似乎没有回调。我想我会在Edit Box
没有on_change
能力的情况下尝试它。除非我用错了,否则我InvalidateControl
仍然可以输入Edit Box
.
Sub GetVersion(control As IRibbonControl, ByRef sVversion)
sVversion = ThisWorkbook.Sheets("Sheet1").Range("A1").Text
myRibbon.InvalidateControl "GetVersion"
End Sub
有人有什么建议吗?
我考虑过的其他想法是一个按钮控件,它以MsgBox
or显示版本UserForm
,或者一个没有功能的按钮,只显示一个SuperTip
.
解决方案
labelControl提供以下回调和属性:
enabled, getEnabled, getLabel, getScreentip, getShowLabel, getSupertip, getVisible, id, idMso, idQ, insertAfterMso, insertAfterQ, insertBeforeMso, insertBeforeQ, label, screentip, showLabel, supertip, tag, visible
getLabel
回调获取控件的标签并具有以下签名:
C#: string GetLabel(IRibbonControl control)
VBA: Sub GetLabel(control As IRibbonControl, ByRef label)
C++: HRESULT GetLabel([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrLabel)
Visual Basic: Function GetLabel(control As IRibbonControl) As String
您似乎刚刚选择了错误的签名,并且 Office 运行时无法找到功能区 XML 中指定的回调。
您可以在以下系列文章中阅读有关 Fluent UI(又名 Ribbon UI)的更多信息:
推荐阅读
- c++ - 在我自己的命名空间中定义 size_t 会产生歧义或其他错误吗?
- sql - NVL 在查询中使用案例
- android - 无法修复意图方案
- c - 有没有办法在 C 中为 i_block 创建迭代器样式函数?
- debugging - 调试 .NET Core 源
- java - 如何以编程方式删除重复的联系人?
- html - 无法在简单的引导页面上的图像框之外获取标题
- c# - What are other alternatives to using e.Cancel = true in Validating event?
- c++ - Get size of vector elements at compile time (even if it is empty) using the Visual Studio compiler
- c# - Keeping TCP connection alive