During runtime, the user is able to add any number of ActiveX command buttons to Sheet 1. I need to have a reference to these new buttons with VBA, but am not sure how.
Suppose you have a command button (OLE object) with the name 'cmdOriginal' and you want to copy that button and paste it on the same workheet and change the name and caption of the new button into "cmdButtonCopy" and "This is a copy". The newly added button has the highest index in the OLEObjects collection! Place the following code in the code section of the worksheet
Sub x1()
Me.OLEObjects("cmdOriginal").Copy
Me.Paste
With Me.OLEObjects(Me.OLEObjects.Count)
.Name = "cmdButtonCopy"
.Caption = "This is a copy"
End With
End Sub