Identifying Control type

  • Thread starter Thread starter Graham Payne
  • Start date Start date
G

Graham Payne

Hi,
When looping through all the controls collection on a form is there a
property that can be examined to determine what type of control each control
is?
Graham
 
Graham,

Two approaches.

Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Sub FindOutWhatKind()
Dim Ctrl As MSForms.Control
For Each Ctrl In UserForm1.Controls
MsgBox TypeName(Ctrl)
Next
Set Ctrl = Nothing
End Sub

Sub FindOutWhatKind2()
Dim Ctrl As MSForms.Control
For Each Ctrl In UserForm1.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
MsgBox Ctrl.Name
ElseIf TypeOf Ctrl Is MSForms.CommandButton Then
MsgBox Ctrl.Name
'more ElseIf
End If
Next
Set Ctrl = Nothing
End Sub
'----------


"Graham Payne" <[email protected]>
wrote in message
Hi,
When looping through all the controls collection on a form is there a
property that can be examined to determine what type of control each control
is?
Graham
 

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

Back
Top