- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个应用程序,我是第一次在其中使用功能区。我可以填充自己的控件并使子例程的回调没有问题。我现在正处于开发阶段,我希望动态隐藏/显示一些组以提供更好的用户体验。
我可以通过更改 CallbackGetVisible 中的可见属性在工作簿加载期间隐藏/显示该组,但是当我更改该值并在应用程序运行时调用 RefreshRibbon 时,它会在 Rib.Invalidate 处中断。测试显示 Rib (IRibbonUI) 对象 (Rib) 设置为空。有没有办法让对象保持事件状态,或者我还缺少其他东西吗?
XML
<!-- This is example : Custom tab for your favorite macros part 1 -->
<customUI onLoad="onLoad" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<!-- Add Custom tab to the ribbon with your favorite buttons-->
<!-- The example add three groups to the new tab -->
<!-- On the last tab there is a menu with five options-->
<ribbon>
<tabs>
<tab id="MyCustomTab" label="MIS DASHBOARD" insertAfterMso="TabHome">
<group id="customGroup1" label="Menus">
<menu id="MyDropdownMenu1" label="Dashboard" size="large" imageMso="ChartTypeOtherInsertGallery">
<button id="customButton1" label="Dashboard Filters" onAction="ShowfrmDashboardFilters" imageMso="ViewsLayoutView" />
</menu>
<menu id="MyDropdownMenu2" label="Reports" size="large" imageMso="SlideMasterChartPlaceholderInsert">
<button id="customButton2" label="Hub Templates" onAction="ShowfrmReportsTemplates" imageMso="CreateTableTemplatesGallery" />
<button id="customButton3" label="Enter Exceptions" onAction="ShowfrmReportsExceptions" imageMso="TableDesign" />
</menu>
<menu id="MyDropdownMenu3" label="Admin" size="large" imageMso="FileDocumentEncrypt">
<button id="customButton8" label="Data Entry" onAction="ShowfrmAdminDataEntry" imageMso="TableDesign" />
<button id="customButton10" label="Manage Business Priorities" onAction="ShowfrmAdminBP" imageMso="QueryShowTable" />
<button id="customButton11" label="Manage Templates" onAction="ShowfrmAdminTemplates" imageMso="CreateTableTemplatesGallery" />
<button id="customButton12" label="Manage Metric Templates" onAction="ShowfrmAdminMetrics" imageMso="AccessListAssets" />
</menu>
<menu id="StaffDatabaseMenu" label="Staff Database" size="large" imageMso="CreateTableTemplatesGallery">
<button id="customButton50" label="Update Data" onAction="ShowfrmStaffDatabase" imageMso="CreateTableTemplatesGallery" />
<button id="customButton51" label="Add" onAction="ShowfrmStaffDatabaseAdd" imageMso="MailMergeRecipientsEditList" />
<button id="customButton52" label="Delete" onAction="ShowfrmStaffDatabaseDelete" imageMso="PageMenu" />
</menu>
<menu id="MyDropdownMenu10" label="Local Data" size="large" imageMso="CreateReportFromWizard">
<button id="customButton60" label="EWB" onAction="ShowfrmEWB" imageMso="CreateReportFromWizard" />
</menu>
</group>
<group id="customGroup4" label="Support">
<button id="customButton20" label="Feedback" size="large" onAction="ShowFeedback" imageMso="FileSendMenu" />
<button id="customButton21" label="Guidance" size="large" onAction="ShowGuidance" imageMso="TentativeAcceptInvitation" />
<button id="customButton22" label="Change Control" size="large" onAction="ShowChangeControl" imageMso="ReviewDisplayForReview" />
</group>
<group id="customGroup5" label="Actions" getVisible="CallbackGetVisible">
<button id="customButton30" label="Save" size="large" onAction="ShowGuidance" imageMso="ExportToVCardFile" />
<button id="customButton31" label="Cancel" size="large" onAction="ShowGuidance" imageMso="OmsDelete" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
代码
Option Private Module
Option Explicit
Const errModule As String = "modRibbon"
'Module Variables
Dim Rib As IRibbonUI
Public MyTag As String
Sub CallbackGetVisible(control As IRibbonControl, ByRef visible)
visible = True
End Sub
Sub RefreshRibbon()
Debug.Print "RefreshRibbon"
If Rib Is Nothing Then
MsgBox "Error, Save/Restart your workbook"
Else
Rib.Invalidate
End If
End Sub
'==================================================================================================================================================================
'Called On Load From XML
'==================================================================================================================================================================
Sub onLoad(ByVal ribbon As IRibbonUI)
On Error GoTo err_Handle
Const strError As String = "Error - Please Contact " & gblDeveloper & " Quoting 'OnLoad'"
Set Rib = ribbon
Rib.ActivateTab ("MyCustomTab")
GoTo Cleanup
'Set Any Objects to Nothing, Exits Sub
Cleanup:
Set Rib = Nothing
Exit Sub
'Throw Error
err_Handle:
errMsg strError & Chr(10) & Err.Description & Chr(10) & errModule
Resume Cleanup
End Sub
编辑
我的印象是 Rib.Invalidate 将导致 CallbackGetVisible 运行,因此相应地设置 Group 的可见属性。但当功能区为空时,Invalidate 将不会运行。
最佳答案
您在子 onLoad
的 Cleanup:
部分将 Rib
设置为 Nothing
。
删除该行,只要保存 Rib
变量的代码模块打开,您就可以使用 Rib
对象。
关于vba - 动态控制 VBA 功能区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33297638/
如何在 WPF 的功能区中隐藏快速访问工具栏? 最佳答案 对于 Microsoft Ribbon for WPF ,您可以使用 VisualTreeHelper 隐藏它.关于 Loaded事件处理程序
我尝试做一个功能区工具栏。我的问题是它没有找到 ImageSource。这是我的简单代码:
如何尽可能快速、简单地添加自定义宏 XLAM 文件? 我有一个保存为 XLAM 文件的宏。我希望我工作的其他不懂 Excel 的人员能够下载 XLAM 文件,像使用任何其他加载项(例如 Solver)
我在带有 EditBox 的 excel 功能区上有一个自定义选项卡。用户应在 EditBox 中输入 100 到 200 之间的数字。如果用户输入除此之外的任何内容,则应弹出错误消息,并且 Edit
我想在 ggplot2 中绘制一个图 多行, 每个都有一个环绕的丝带, 用户指定颜色, 并带有显示线条颜色和色带颜色的图例。 (向下滚动以查看几乎实现我所寻求的情节的示例。) 我看过相关的问题,但没有
.xlsm > customUI > customUI.xml 当我为下面的菜单元素使用 size="large"时,我看到带有大图标的按钮。 但是当我将属性 size="large"的按钮放在菜单
我正在开发 PowerPoint 加载项,并希望在加载项应用程序运行时暂时禁用某些功能区控件。 我开发了一个解决方案,可以在启用加载项时按预期工作,但这还不够,因为它禁用了一些常用的控件,如 Slid
如何为 Excel 功能区中的每个组合框项目设置 ID? 下面的代码是我为每个项目设置文本(标签)的地方,我想为每个项目设置一个 ID,以便以后识别它。我怎样才能做到这一点? Private Sub
我有一个应用程序,我是第一次在其中使用功能区。我可以填充自己的控件并使子例程的回调没有问题。我现在正处于开发阶段,我希望动态隐藏/显示一些组以提供更好的用户体验。 我可以通过更改 CallbackGe
我正在为 Office(2007 年和 2010 年)编写一个插件,到目前为止,我已经使用 Fluent Ribbon XML 来自定义不同的功能区。 我现在使用这种方法时遇到的问题是,我想在我的代码
我刚开始玩 Microsoft 的 08/2010 WPF Ribbon发布。基础知识看起来非常简单,但我如何创建一个 RibbonToggleButton 组,一次只允许选择组中的一个按钮,类似于单
我引用CSS3-Tricks Ribbon tutorial的教程. 我想用 CSS3 调整表格内的第 th 元素,使其看起来像教程中的功能区。 我设置了一个 JSFiddle测试它,但不幸的是我做不
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或include a mi
我正在设计一个网站,该网站的左上角悬挂着一条 CSS 丝带。当我将图像放在色带下方时,色带会与图像重叠,这就是我想要的外观。 但是,当我实现 J-Query 幻灯片放映技术时,会发生以下情况。 我的问
我试图在 Div 的右上角放置一个“三 Angular 形”。不知何故,我每次都搞砸了。 That's the Fiddle 那是我的 div: Test Module
我是 VSTO 的新手,我正在尝试创建一个带有一些简单控件的 Excel 功能区。我知道在 Visual Studio 中有两种方法可以做到这一点。功能区 XML 和功能区设计器,据我所知,大多数人更
我听说 Microsoft 允许使用商用 Office UI 控件,但竞争产品除外,例如文字处理器或电子表格应用等。 这有多真实? 此外,如果这不是真的,您是否知道任何免费功能区控件? 最佳答案 你应
如何更改 WPF 功能区 ApplicationMenu 中 AuxilaryPane 的大小?我已将最近的文件列表添加到该区域,但它被截断了。理想情况下,我希望辅助 Pane 像 Word/Exce
我正在学习 Micronaut 框架。我的 gradle.build 文件 dependencies { annotationProcessor "io.micronaut:micronaut-inj
我正在考虑在我的一个应用程序中实现功能区 GUI,当然希望遵守 MS 指南,因此感觉就像一个普通的功能区,等等。但我正在尝试找出解决特定问题的方法动态改变功能区。 我正在创建一个概念游戏编辑器,请不要
我是一名优秀的程序员,十分优秀!