새로 생성 된 ActiveX 버튼의 이름을 바꾸는 방법은 무엇입니까?

Nov 26 2020

당 마티유의 답변 , 나는 통해 액티브 버튼을 만들 수 관리

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

버튼의 이름을 어떻게 바꿀 수 있습니까?

불행히도 이러한 링크는 솔루션으로 연결되지 않았습니다.

  • Excel ActiveX ListBox의 이름 변경

  • https://answers.microsoft.com/en-us/msoffice/forum/all/vba-code-to-modify-the-name-property-of-an-activex/d23b4ee5-aef4-425b-8a19-2899b65651e2

시트의 모듈에 관련 코드를 추가 할 수 있기 때문에 매우 영광 스럽습니다 (내가 볼 수있는 한 관련 하위는 항상 호출 됨 [insert button name]_Click).

답변

1 SiddharthRout Nov 26 2020 at 17:03

이것이 당신이 시도하는 것입니까?

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