Is that what you are trying?
Set shp = ActiveSheet.Shapes(Selection.Name) shp.Name = "Node" & Str(NumNodes) With shp.OLEFormat.Object .Object.Caption = "Node" & Str(NumNodes) End With
Followup
Just tried this and it works ...
Public Sub Node_Button_Duication() Dim shp As Shape Dim NumNodes As Long 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 NumNodes = 5 Set shp = ActiveSheet.Shapes(Selection.Name) shp.Name = "Node" & Str(NumNodes) With shp.OLEFormat.Object .Object.Caption = "Node" & Str(NumNodes) End With End Sub
LEARN MORE
try it
Set shp = ActiveSheet.Shapes(Selection.Name) With shp.OLEFormat.Object .Object.Caption = "Node" & Str(NumNodes) .Name = "Node" & NumNodes End With
Notice I changed Str(NumNodes)
to NumNodes
?
ActiveX control names cannot have spaces :)
Try now.
Snapshot
source share