+ Reply to Thread
Results 1 to 2 of 2

eventhandling of dynamically created form components

Hybrid View

  1. #1
    Registered User
    Join Date
    02-26-2009
    Location
    Liberec, Czech republic
    MS-Off Ver
    Excel 2003
    Posts
    1

    eventhandling of dynamically created form components

    Hello everybody,
    after a few hours of googling i decided to ask for help.

    Im writing a VBA macro/application (excel 2003) where i dynamically generate components on form. What i need is to handle events (change) of checkbox. I found an perfect example, but it is for ComboBox. Converting to checkbox is severe problem for me.. After trying to change combox to checkbox i get error:

    Compile error:
    Object does not source automation events

    Perfectly working source is following - when replacing two lines by commented ones, i keep gettin error mention above.


    Option Explicit
     
     Dim WithEvents cboNew As ComboBox
    'Dim WithEvents cboNew As CheckBox
     
    Private Sub CommandButton1_Click()
     
    'Set cboNew = Controls.Add("Forms.CheckBox.1", "cboNew")
     Set cboNew = Controls.Add("Forms.ComboBox.1", "cboNew")
     
    End Sub
     
    Private Sub cboNew_Change()
        MsgBox "Dynamically created form component has changed."
    End Sub
    Last edited by VBA Noob; 02-26-2009 at 12:20 PM.

  2. #2
    Forum Contributor
    Join Date
    12-11-2004
    MS-Off Ver
    2007
    Posts
    137

    Re: eventhandling of dynamically created form components

    Hi,

    Replace

    Dim WithEvents cboNew As CheckBox
    by

    Dim WithEvents cboNew As msforms.CheckBox
    Regards
    michel
    Last edited by michelxld; 03-01-2009 at 07:37 AM.

+ 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