4
나는 다음과 같은 코드를 VBA로 액티브 명령 단추의 이름 속성을 변경하려고
:
Set shp = ActiveSheet.Shapes(Selection.Name)
With shp.OLEFormat.Object
.Object.Caption = "Node" & Str(NumNodes)
.Name = "Node" & Str(NumNodes)
End With
나는를 변경할 수 있어요 캡션 이름이지만 위의 코드로는 name 속성을 변경할 수 없습니다. name 속성에 대해 문자열을 int (NumNodes)와 연결하는 방법을 찾아야합니다.
UPDATE
이것은 복사하는 특정 셀 위치에 명령 버튼을 페이스트 전체 서브 루틴이다. 버튼 생성시 이름과 캡션과 같은 속성도 변경됩니다.
Public Sub Node_Button_Duplication()
'
'Comments: Copies and pastes Node 1's button to the appropriate column
Dim shp As Shape
' Copy Node 1 button and paste in appropriate location
ActiveSheet.Shapes("CommandButton1").Select
Selection.Copy
Cells(5, 10 + 7 * (NumNodes - 1) - 1).Select
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft 47.25
Selection.ShapeRange.IncrementTop -13.5
Set shp = ActiveSheet.Shapes(Selection.Name)
With shp.OLEFormat.Object
.Object.Caption = "Node" & Str(NumNodes)
.Name = "Node" & Str(NumNodes)
End With
End Sub
예. 결과적으로 명령 단추 이름은 "CommandButton4"로 유지됩니다. – Ehudz
방금 해봤습니다. 그것은 새로 만든 된 명령 단추의 이름을 변경합니다. –
** NAME ** 및 ** Caption **뿐만 아니라 ** Caption **? VB 편집기에서 이름 필드 여전히 단추를 만든 후 CommandButton4 말한다 – Ehudz