LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Event procedures for controls added with CreateEventProc

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
.... add the text for the procedure..

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)

Another complication is that 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.

Many thanks,
--
John Austin
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event procedures for controls added with Controls.Add John Austin[_4_] Excel Programming 1 March 9th 05 03:31 PM
learning event procedures R.VENKATARAMAN Excel Programming 4 January 21st 05 01:09 PM
Event procedures (and the temple of doom) Mark Tangard[_3_] Excel Programming 2 July 20th 04 04:45 PM
Event Procedures: Event on Worksheet to fire Event on another Worksheet Kathryn Excel Programming 2 April 7th 04 07:35 PM
Creating Event procedures from a macro Robert Stober Excel Programming 3 September 7th 03 06:52 PM


All times are GMT +1. The time now is 11:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"