ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform and controls locked property (https://www.excelbanter.com/excel-programming/283823-userform-controls-locked-property.html)

D.S.[_3_]

Userform and controls locked property
 
Can I lock all userform controls by code upon form activation?

D.S.

Vasant Nanavati

Userform and controls locked property
 
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


"D.S." wrote in message
...
Can I lock all userform controls by code upon form activation?

D.S.



Harald Staff

Userform and controls locked property
 
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." skrev i melding ...
Can I lock all userform controls by code upon form activation?

D.S.

D.S.[_3_]

Userform and controls locked property
 
Thanks to both. The reason I want to do this?

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.
"Harald Staff" wrote in message ...
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." skrev i melding ...
Can I lock all userform controls by code upon form activation?

D.S.


All times are GMT +1. The time now is 11:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com