Hi Doug,
To assist you further with Microsoft Office concern, it would be best to post your query here.
Regards.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a large project that will have many (~15) userform Frames, each of which will contain 600 controls (150 labels that are captioned at run time and 450 option buttons (150 groups of 3).
Having gone through the tedious task of setting up the first frame and assigning unique names to each of the 600 controls, and copying that frame to another userform for the purpose of being able to work on it, I was looking for a way to use VBA to rename each of the controls for which I came up with the following code
Sub rename()
With Application.VBE.ActiveVBProject.VBComponents.Item("frmWorkSpace").Designer.Controls("S05")
For i = 1 To .Controls.Count
If Left(.Controls(i).Name, 4) = "QS04" Then
.Controls(i).Name = "QS05" & Mid(.Controls(i).Name, 5)
End If
Next i
End With
End Sub
While the code does exactly what I need it to do, in that it successfully renames each of the controls, when it is run, it results in
and when I click on Debug, I see:
Does anyone have an idea why that error is occuring, or another way of re-naming controls using VBA?
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Hi Doug,
To assist you further with Microsoft Office concern, it would be best to post your query here.
Regards.
So just what is the purpose of the Microsoft Office Programming Forum if it is not to ask questions about programming the Office applications?
The issue that I raised had nothing at all to do with Planning, Deployment and Compatibility.
The issue with my code was that the array of controls is indexed from 0. Therefore, I should have been using:
For i = 0 To .Controls.Count - 1