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
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
news:[email protected]...
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
Jim,
thanks for that it works atreat.
Regards,
Graham
"Jim Cone" <[email protected]> wrote in message
news:[email protected]...
> 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
> news:[email protected]...
> 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
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks