我发现这些其他问题here and here有点太高级了。我只需要一种简单的方法即可在运行VBA代码时更改ActiveX命令按钮“ CommandButton1”的标题。我敢肯定它可以比其他示例更简单吗?
答案 0 :(得分:4)
对于不在工作表模块中运行的代码(Sheet1
是工作表Code Name):
Sheet1.CommandButton1.Caption = "Text"
对于在工作表模块中运行的代码,不需要Sheet1.
部分。
答案 1 :(得分:1)
我认为它不会比这更简单:
Sub test()
Dim sht As Worksheet
Set sht = ThisWorkbook.Worksheets("Name of your Worksheet") 'the worksheet in which the button is located
sht.OLEObjects("Name of your Command Button").Object.Caption = "test"
End Sub