Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Class Frame Click event (Excel 2003)

    Hi all,

    I am trying to use a class module with the public events click event on a Frame within a Userform, can someone tell me if this is possible and if it is please check the code that I have to see if there is a mistake within it.

    Class Module

    Public WithEvents Framegroup As MSForms.frame
    Private Sub Framegroup_Click()
    MsgBox "TADA"
    End Sub


    Normal Mod
    Sub ShowDialog1()
    Dim Framecount As Integer
    Dim ctl As Control
    ' Create objects
    Framecount = 0
    For Each ctl In UserForm1.Controls
    If TypeName(ctl) = "FrPress" Then
    Framecount = Framecount + 1
    ReDim Preserve Framepress(1 To Framecount)
    Set Framepress(Framecount).Framegroup = ctl
    End If
    Next ctl
    UserForm1.Show
    End Sub

    Thanks Darryl.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Class Frame Click event (Excel 2003)

    What is FrPress? The name of the class module? If so, why would the TypeName of a control on the form be FrPress?
    And how is Framepress declared originally?

  3. #3
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Class Frame Click event (Excel 2003)

    Hi Hans,

    FrPress is the name of a Ctl on a form, it's the first 7 characters of 6 Frames, the 8th character is the either A B C D E F, I have used this example before with other controls, the command button, label, and combobox, but I have not tried it with a Frame before, is there something different about the Frame Control that excludes it from other controls?

    The name of the Class is Class1. Framepress is declared within the normal module,

    Dim Framepress() as New Class1

    Thanks, Darryl.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Class Frame Click event (Excel 2003)

    The TypeName of a Frame control is - surprise surprise - "Frame", not "FrPress. Try this line:

    If Left(ctl.Name, 7) = "FrPress" Then

    instead of

    If TypeName(ctl) = "FrPress" Then

  5. #5
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Class Frame Click event (Excel 2003)

    Thank you Hans.

Posting Permissions

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