+ Reply to Thread
Results 1 to 3 of 3

Adding CheckBox Caption to a Listbox

  1. #1
    Peterd
    Guest

    Adding CheckBox Caption to a Listbox

    Could anybody please give me some ideas for this problem.
    Ref:All the controls I have used are ActiveX and emmbedded into a
    worksheet.

    I am trying to loop through a grouped set of checkboxes and if the
    value is true then I want to load the Caption of the checkbox into a
    listbox, or a TextBox. I can get everything to work except loading the
    caption of the checkBox into the listBox. I can get the Caption to load
    into a Listbox if I use the click event of a checkbox itself but I
    can't seem to get it to work within the loop.
    Note: The counter is for testing only.
    Private Sub CommandButton1_Click()
    Dim OLEObj As OLEObject
    i = 0
    For Each OLEObj In ActiveSheet.OLEObjects
    If TypeOf OLEObj.Object Is MSForms.CheckBox Then
    If OLEObj.Object.GroupName = "ImmediateCauseAct" Then
    If OLEObj.Object.Value = True Then
    ListBox1.AddItem OLEObj.Oject.Caption ??Problem Line
    i = i + 1
    End If
    End If
    End If
    Next OLEObj
    MsgBox i
    End Sub


  2. #2
    Bob Phillips
    Guest

    Re: Adding CheckBox Caption to a Listbox

    Private Sub CommandButton1_Click()
    Dim OLEObj As Object
    Dim i As Long
    i = 0
    For Each OLEObj In ActiveSheet.OLEObjects
    If TypeOf OLEObj.Object Is MSForms.CheckBox Then
    If OLEObj.Object.GroupName = "ImmediateCauseAct" Then
    If OLEObj.Object.Value = True Then
    ListBox1.AddItem OLEObj.Object.Caption
    i = i + 1
    End If
    End If
    End If
    Next OLEObj
    MsgBox i
    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Peterd" <[email protected]> wrote in message
    news:[email protected]...
    > Could anybody please give me some ideas for this problem.
    > Ref:All the controls I have used are ActiveX and emmbedded into a
    > worksheet.
    >
    > I am trying to loop through a grouped set of checkboxes and if the
    > value is true then I want to load the Caption of the checkbox into a
    > listbox, or a TextBox. I can get everything to work except loading the
    > caption of the checkBox into the listBox. I can get the Caption to load
    > into a Listbox if I use the click event of a checkbox itself but I
    > can't seem to get it to work within the loop.
    > Note: The counter is for testing only.
    > Private Sub CommandButton1_Click()
    > Dim OLEObj As OLEObject
    > i = 0
    > For Each OLEObj In ActiveSheet.OLEObjects
    > If TypeOf OLEObj.Object Is MSForms.CheckBox Then
    > If OLEObj.Object.GroupName = "ImmediateCauseAct" Then
    > If OLEObj.Object.Value = True Then
    > ListBox1.AddItem OLEObj.Oject.Caption ??Problem Line
    > i = i + 1
    > End If
    > End If
    > End If
    > Next OLEObj
    > MsgBox i
    > End Sub
    >




  3. #3
    Peterd
    Guest

    Re: Adding CheckBox Caption to a Listbox

    So easy, I have spent about a week reading through posts trying to
    solve this, thanks very much bob


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1