Private Sub UserForm_Initialize()
Dim ctl As Control
For Each ctl In Controls
On Error GoTo ErrorHandler
ctl.Locked = True
'ctl.Enabled = False
Next
Exit Sub
ErrorHandler:
If Err.Number = 438 Then Resume Next
End Sub
Why would you want to do this?
--
Vasant
Can I lock all userform controls by code upon form activation?
I should have been more specific, I only needed to disable all the textboxes. I want to prevent the user from making direct entries in the textboxes, as they are intended to be populated only by a procedure that will be triggered.
D.S.
An easier way is to place a set of controls onto a Frame and set the frame's Enabled property to false.
--
HTH. Best wishes Harald
Followup to newsgroup only please
"D.S." <[email protected]> skrev i melding Can I lock all userform controls by code upon form activation?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.