Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Event procedures for controls added with Controls.Add
I need to create event procedures for controls added with Controls.Add.
The following approach was suggested: Private Sub UserForm_Activate() Dim Ct As Control, StartLine as long Set Ct = Me.Controls.Add("Forms.TextBox.1", "txtNew" , True) With ActiveWorkbook.VBProject.VBComponents("UserForm1") .CodeModule StartLine = .CreateEventProc("Change", Ct.Name) + 1 End With But I get a runtime error on the .CreateEventProc call - Error 57017 "Event handler is invalid" Where have I gone wrong? Are there any other approaches (such as control arrays in VB6) Many thanks, -- John Austin |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Event procedures for controls added with Controls.Add
Another complication: When the workbook is protected, the line:
With ActiveWorkbook.VBProject.VBComponents("UserForm1") .CodeModule causes a run-time error. I really need to trap the TextBox change events with the VBA code protected. "John Austin" wrote: I need to create event procedures for controls added with Controls.Add. The following approach was suggested: Private Sub UserForm_Activate() Dim Ct As Control, StartLine as long Set Ct = Me.Controls.Add("Forms.TextBox.1", "txtNew" , True) With ActiveWorkbook.VBProject.VBComponents("UserForm1") .CodeModule StartLine = .CreateEventProc("Change", Ct.Name) + 1 End With But I get a runtime error on the .CreateEventProc call - Error 57017 "Event handler is invalid" Where have I gone wrong? Are there any other approaches (such as control arrays in VB6) Many thanks, -- John Austin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how can I trap the change event (Tab Press key) of these controls | Excel Worksheet Functions | |||
How to manipulate controls added at run-time | Excel Worksheet Functions | |||
how to access programatically added controls | Excel Programming | |||
Changing Event Subs of Controls On Air | Excel Programming | |||
Same event procedure for multiple controls | Excel Programming |