Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Access to Active X code names
I have a series of dynamically generated scrollbars, which I need to
dynamically generate corresponding event handlers for. I'm trying to program VBE to create event procedures, however I've come across a snag: because the event procedure names seem to have to follow the format name_Change(), I need the code name of the right scrollbar. I don't know what it is since I dynamically generate them. I tried renaming the scrollbars in runtime, and it works when the macro is run for the first time since Excel was opened, but after that it names them "ScrollBar1, ScrollBar2" etc. and so my code fails to reference them correctly when creating the event procedure (and crashing Excel...). The only ways I could think of to solve this problem is to either access the code name programmatically, or somehow clear the name history in Excel so it doesn't use those automated names. Does anyone know of a way to to do this, or some other method to get around the problem? I can't seem to find a way to programmatically access the code names of the scrollbars at all! Here's some of the code I have so far. It's part of a For loop, hence the iterative "i". There's just a dummy function for the event procedure. CODE __________________________________________________ __________________________ scrollName = "Scroll" & i barName = "Bar" & i ActiveSheet.OLEObjects.Add(ClassType:="Forms.Scrol lBar.1", Link:=False, _ DisplayAsIcon:=False, Left:=leftValue, Top:=100 + (i - 1) * 36 - 6, Width:=timeDiff / 2, Height:=6). _ Select Selection.Name = scrollName planSheet.Shapes.AddShape(msoShapeRectangle, leftValue, 100 + (i - 1) * 36, timeDiff / 2, 36).Select Selection.Characters.Text = cellStr & vbNewLine & get24HrTime(startTime) & " To " & get24HrTime(endTime) Selection.Name = barName With Selection.Font .Size = 10 .Bold = True End With ActiveSheet.Shapes.Range(Array(scrollName, barName)).Select Selection.ShapeRange.Group.Select Dim StartLine As Long With ActiveWorkbook.VBProject.VBComponents("Sheet8").Co deModule StartLine = .CreateEventProc("Change", scrollName) + 1 .InsertLines StartLine, _ "Msgbox ""Hello World"",vbOkOnly" End With __________________________________________________ ______________________ Thanks in advance for any help!! Regards, Jenny |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
using the Excel generic worksheet names instead of user-given names in code | Excel Discussion (Misc queries) | |||
list sheet names vertically below the active cell - need macro. | Excel Worksheet Functions | |||
VBA access to Active X Scroll Bar | Excel Programming | |||
Excel Spreadsheet from Access. List of names changes as names are | Excel Discussion (Misc queries) | |||
hidden names in active workbook | Excel Worksheet Functions |