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: 5
Default Late Bound Object Click Events

Hello,

I concider myself to be a self taught intermediate programmer so bear with me:
I am using Excel 2000 VBA to create a custom dialog to run sorting features
in a spreadsheet. I have a configuration menu consisting of a multipage
object that I have left blank (without any tabs) in design mode. After the
macro is initialized it looks to a sheet in the top row for the names it
needs to create the multipage tabs, below each name is a list of codes that
the type will look for. Each tab denotes a filter name type. On those new
tabs I place listboxes to insert filter codes for those types and I set the
listbox names to "lbxType" & X. where X is the number of the tab it is
currently setting up and I'm hoping to use it as an enumeration tool later.
This is the only way I know of to set this up to be dynamic at runtime as
filter types and codes can come and go and even change order. As far as the
setup process is concerned it runs perfectly. It creates all the tabs and
listboxes and within each listbox all the types are correctly listed. The
idea is to create a nice interface where a user can configure which filters
to use and to add new filter codes when they come along without messing with
the spreadsheet which I'm trying to keep protected from human input errors.

Now, here is the problem I am running into:
I CAN raise a click event for the tabs since the multipage object existed
before runtime and heres a kicker: In the click event for the multipage
object I can have it tell me the index of my selection in the listbox but I
CAN'T seem to raise a click event on any of the listboxes created on the new
tabs. I can pause the macro while it is running and watch all the variables
of the form and see that the names on the listboxes were labeled correctly
but I cannot get it to respond to a Private Sub lbxType1_click() event. I've
also tried an array naming convention for the listboxes and entered the code:
Private Sub lbxType_Click(ByVal Index as Integer) to no avail.
How do I raise a click event for an object created at runtime?

Here is a bit of the code used to load the multipage object:
For reference, arrType is a two dimentional array preloaded with the
category names and associated codes.

ReDim ctrTDesc(UBound(arrType, 1))
ReDim ctrTList(UBound(arrType, 1))
For X = 1 To UBound(arrType, 1)
'Adding a new tab and setting it's name!
frmConfig.mpgType.Pages.Add (arrType(X, 1))
'Creates a label object and sets it to display the filter category name
Set ctrTDesc(X) = frmConfig.mpgType.Pages(X -
1).Controls.Add("Forms.Label.1")
ctrTDesc(X).Left = 5
ctrTDesc(X).Top = 5
ctrTDesc(X).Width = 200
ctrTDesc(X).Height = 25
ctrTDesc(X).Caption = arrType(X, 1)
ctrTDesc(X).FontSize = 10
ctrTDesc(X).Font.Bold = True

'Creates a listbox to input filter codes into
Set ctrTList(X) = frmConfig.mpgType.Pages(X -
1).Controls.Add("Forms.ListBox.1")
ctrTList(X).Name = "lbxType" & X ' my problem seems to revolve
around this but not sure.
ctrTList(X).Left = 5
ctrTList(X).Top = 20
ctrTList(X).Width = 75
ctrTList(X).Height = 150

'Loads the filter codes into the listbox
For Y = 3 To UBound(arrType, 2)
If arrType(X, Y) < "" Then ctrTList(X).AddItem (arrType(X, Y))
Else Exit For
Next Y
Next X



 
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
Late Binding issue with Excel.Application object [email protected][_2_] Excel Discussion (Misc queries) 2 August 4th 09 08:10 AM
Late binding to Excel from Access causing Object error EagleOne@microsoftdiscussiongroups[_2_] Excel Discussion (Misc queries) 4 June 14th 08 12:45 AM
Click events on Ecel Cells aftamath Excel Discussion (Misc queries) 4 September 28th 05 04:35 PM
Click events on charts Steve Excel Programming 3 May 29th 04 03:26 AM
VBA References - when is Office Object Library Reference set? Best practice re. Early/Late binding ... AndyB Excel Programming 5 April 22nd 04 02:11 PM


All times are GMT +1. The time now is 03:52 PM.

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"