Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Pennsylvania, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Value of checkbox (Word 2000 VBA)

    I'm a novice having difficulty iterating through a set of controls within a frame on a Word 2000 VBA userform. The frame will contain checkboxes along wtih other controls that I do not want to touch as I iterate through the controls in the frame.There's obviously something fundamentally wrong with my line of attack, and I hope one of you will please set me straight.

    Private Sub UserForm_Initialize()
    Dim oBox As Control
    For Each oBox In Me.Frame1.Controls
    If TypeOf oBox Is CheckBox Then
    Debug.Print oBox.Name
    Debug.Print oBox.Caption
    Debug.Print oBox.Value
    End If
    Next
    End Sub

    If I omit the "If" and "End If " it runs as expected, but I need to exclude the non-checkbox items. There must be a simple way to loop through only the checkboxes in the frame. True? Thanks in advance.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Value of checkbox (Word 2000 VBA)

    Try the following :<pre>For Each oBox In Me.Frame1.Controls
    If TypeName(oBox ) = "CheckBox" Then
    Debug.Print oBox.Name
    Debug.Print oBox.Caption
    Debug.Print oBox.Value
    End If
    Next</pre>

    Andrew C

  3. #3
    Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Pennsylvania, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Value of checkbox (Word 2000 VBA)

    Thank you so much for the accurate and EXTREMELY rapid (20 minutes, probably a new record!) response to my question. You've saved me a night's sleep. This lounge is a life saver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •