Renaming checkBoxes in VBA (continuously)

Antoine.c -  
 Antoine.c -
Hello, I can help translate the user text from French to English, preserving the HTML structure. Translation: Hello,

I’m trying to rename checkboxes under VBA but it doesn’t work.
I can’t find adequate help. I found something in THE VBA FAQ but I didn’t understand anything
(it’s not for lack of searching, it’s that I’m really not good)

Here is the code I want to improve:

Sub test() Dim p, i As Integer p = 1 debut: While p < 38 i = i + 1 ConstatAnomalie.Controls("CheckBox" & i).Name = "ChB" & p On Error GoTo GestError p = p + 1 Wend GestError: If Err.Number = -2147024809 Then test = "" GoTo debut Else MsgBox Err.Number & " " & Err.Description GoTo fin End If fin: End Sub


Here’s what I found under THE VBA FAQ:

-------------------------------------- 'Procedure for creating CheckBoxes to place in the UserForm. 'The UserForm must already contain a button named CommandButton1 Option Explicit Private Sub CommandButton1_Click() Dim Obj As Control Dim Cl As Classe1 Dim i As Integer Set Collect = New Collection For i = 1 To 3 'loop to create CheckBoxes Set Obj = Me.Controls.Add("forms.Checkbox.1") With Obj .Name = "moncheckbox" & i .Object.Caption = "le texte" & i .Left = 140 .Top = 30 * i + 10 .Width = 50 .Height = 20 End With 'add the object into the class Set Cl = New Classe1 Set Cl.ChkBx = Obj Collect.Add Cl Next i End Sub '--------------------------------------


I feel a bit useless, but it’s been ages and I’m not making progress.

Thank you, again
Configuration: Windows XP Internet Explorer 6.0

2 answers

  1. Antoine.c
     
    Yes, it’s the NAME of the CheckBox that I want to change.

    The ".Name"

    It’s actually this line that blocks in my code

    ConstatAnomalie.Controls("CheckBox" & i).Name = "ChB" & p

    Thanks
    3
  2. epsilon17 Posted messages 83 Status Member 55
     
    Do you want to change the name of the checkbox or the text next to it?

    for the text it’s more like Caption
    --
    “In searching carefully, you’ll find it” … “(or not)”
    0