Protecting Excel Custom UI Ribbon

我的梦境 提交于 2020-01-03 04:07:09

问题


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.

For instance, you can get the value of the label of built-in command with this

    MsgBox Application.CommandBars.GetLabelMso("PasteSpecialDialog")

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

Thanks.


回答1:


Loop through each command bar in excel.

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

end if
Next


来源:https://stackoverflow.com/questions/23577976/protecting-excel-custom-ui-ribbon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!