Hello,
I have a problem when I try to modify the code name (not the caption !) of a checkbox.
In the sample code at the bottom of this post, I delete the previous checkboxes if any and I create 2 new ones.
If I run this code from a brand new file, everything works fine. Both code name and caption are ok for the 2 checkboxes.
But if I save the file and run it another time, the code name of the first checkbox is not updated as shown below :

This means that this renaming method doesn't work if ActiveX controls are already present in the Excel file.
I use a similar code in my project. It contains many ActiveX controls like checkboxes, listboxes, command buttons ... and all of them need to be present when opening the Excel file. The user can bring some modifications that lead to the re-creation of few
checkboxes. The simplified code below is used to do this. But this problem generates compilation errors. I can rename all the controls manually but this is quite painful so I would like to solve this problem.
Here is the code used :
***************************************************************************
Private Sub Workbook_Open()
Dim OLEObj As OLEObject
Dim Index As Byte
Dim Chkbox As OLEObject
Const CheckName = "MyCheckBox"
'Delete previous objects
For Each OLEObj In ActiveSheet.OLEObjects
OLEObj.Delete
Next OLEObj
'Create 2 checkboxes
For Index = 1 To 2
'Add a new checkbox
Set Chkbox = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Left:=40, Top:=40 * Index, Width:=120, Height:=30)
'Change the name and the caption of the checkbox
Chkbox.Name = CheckName & Index
Chkbox.Object.Caption = CheckName & Index
Next
'Destroy the object
Set Chkbox = Nothing
End Sub
***************************************************************************
Any ideas ?
Thanks a lot for your help.