首页 > 解决方案 > 如何在 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

有人有什么建议吗?

我考虑过的其他想法是一个按钮控件,它以MsgBoxor显示版本UserForm,或者一个没有功能的按钮,只显示一个SuperTip.

标签: excelvbaribbon

解决方案


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)的更多信息:


推荐阅读