保护Excel自定义UI功能区 [英] Protecting Excel Custom UI Ribbon

查看:230
本文介绍了保护Excel自定义UI功能区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目的是编写VBA来检查自定义功能区按钮标签是否已更改。
在Workbook_Open事件中,vba将获取自定义功能区的特定按钮的标签值,并将其与VBA中的硬编码值进行比较。如果它们不一样,vba将关闭工作簿。

The purpose is to write a VBA to check to see if the custom Ribbon button label was changed. Upon Workbook_Open event, the vba will get the label value of a specific button of custom Ribbon and compared it with a hardcoded value in VBA. If they are not the same the vba would close the workbook.

例如,您可以使用此

    MsgBox Application.CommandBars.GetLabelMso("PasteSpecialDialog")

但是如何获取自定义功能区按钮的标签值? GetLabel不会做这个工作。

But how to get the value of the label of custom ribbon button? GetLabel does not do the job.

谢谢。

推荐答案

循环通过excel中的每个命令栏。

Loop through each command bar in excel.

For Each bar In Application.CommandBars 
if condition = true then
  'Your code here

end if
Next

这篇关于保护Excel自定义UI功能区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆