问题
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