如何重命名新建的 ActiveX 按钮?

How to rename a newly created ActiveX button?

根据 ,我设法通过

创建了一个 ActiveX 按钮
Sub aaaaaaaa()
Dim newButton As Object
Set newButton = Sheets(sheetname_KvE).OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
    Link:=False, _
    DisplayAsIcon:=False, _
    Left:=800, _
    Top:=0, _
    Width:=300, _
    Height:=30).Object
With newButton
    .Caption = "bla"
    '.Name = "Button_what" ' - THIS DOES NOT WORK!
End With
End Sub

如何重命名该按钮?

不幸的是,这些链接并没有引导我找到解决方案:

这将是非常光荣的,因为它使人们能够在 sheet 的模块中添加相关代码(据我所知,它们相关的子总是称为 [insert button name]_Click)。

这是你正在尝试的吗?

Sub Sample()
    Dim newButton As OLEObject
    Dim ws As Worksheet
    
    Set ws = Sheets(sheetname_KvE)
    Set newButton = ws.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
                                      Link:=False, _
                                      DisplayAsIcon:=False, _
                                      Left:=800, _
                                      Top:=0, _
                                      Width:=300, _
                                      Height:=30)
    newButton.Object.Caption = "bla"
    newButton.Name = "Button_what"
End Sub