looping through userform controls changing enabled and locked properties

J

JulieD

Hi All

i'm trying to (Excel 2000) loop through userform controls which are set to
enabled = false & locked = true to change them to enabled = true and locked
= false on the On Click of a command button.

I have John Walkenbach's book (excel 2002) where he shows code for looping
through controls but i can't seem to find a way to get to either the enabled
or locked properties - everything i tried resulted in excel crashing !

Help!

Thanks
JulieD
 
N

Nigel

This will switch the state of the control as you required, incorporate this
into your control loop to act on each control.

Private Sub CommandButton1_Click()
With TextBox1
If .Enabled Then
.Enabled = False
.Locked = True
Else
.Enabled = True
.Locked = False
End If
End With
End Sub

Cheers
Nigel
 
B

Bob Phillips

Julie,

Here is an example

Dim ctl As msforms.Control

For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then
If ctl.Enabled Then
MsgBox ctl.Name
End If
End If
Next ctl

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

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.

Ask a Question

Top