Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
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
using the Excel generic worksheet names instead of user-given names in code Paul Excel Discussion (Misc queries) 5 June 26th 09 08:44 PM
list sheet names vertically below the active cell - need macro. Eddy Stan Excel Worksheet Functions 2 September 28th 07 07:48 PM
VBA access to Active X Scroll Bar CodeJunky Excel Programming 2 December 20th 05 10:21 PM
Excel Spreadsheet from Access. List of names changes as names are Gordy w/Hi Expectations Excel Discussion (Misc queries) 1 October 21st 05 03:30 AM
hidden names in active workbook hamcdo Excel Worksheet Functions 2 June 1st 05 05:46 PM


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

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

About Us

"It's about Microsoft Excel"