Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically Generating Controls At Runtime Issue

Status
Not open for further replies.

Kaah

Programmer
Feb 25, 2001
40
AU
Hi all,

Has anyone tried to dynamically generate activex controls straight onto an excel sheet? I have been messing about with it and am almost there with it but I at present have one last issue to sort out. This is the important code so far. It loops through an array and for each array cell makes a new text label, positions it, names it, captions it, colours it, etc....

'**********************************************************

'\\paste into code window to read properly- sorry bout the mess here!
For iCount = LBound(vSetMemberArray) To UBound(vSetMemberArray)
iButtonCount = iButtonCount + 1
iTopPosition = iTopPosition + 30
ThisWorkbook.Worksheets("xlsMainMenu").OLEObjects.Add ClassType:="Forms.Label.1", Link:=False, _
DisplayAsIcon:=False, Left:=iLeftPosition, Top:=iTopPosition, Width:=132.75, Height _
:=21
sMembername = DescriptionToName("Entity", vSetMemberArray(iCount))
ThisWorkbook.Worksheets("xlsMainMenu").OLEObjects(iButtonCount).Name = "lbl" & sMembername
ThisWorkbook.Worksheets("xlsMainMenu").OLEObjects(iButtonCount).Object.Caption = vSetMemberArray(iCount)
ThisWorkbook.Worksheets("xlsMainMenu").OLEObjects(iButtonCount).Object.Font.Name = "Century Schoolbook"
' ThisWorkbook.Worksheets("xlsMainMenu").OLEObjects(iButtonCount).Object.Font.Italic = True
ThisWorkbook.Worksheets("xlsMainMenu").OLEObjects(iButtonCount).Object.Font.Size = 8
ThisWorkbook.Worksheets("xlsMainMenu").OLEObjects(iButtonCount).Object.TextAlign = 2
ThisWorkbook.Worksheets("xlsMainMenu").OLEObjects(iButtonCount).Object.BackStyle = fmBackStyleTransparent
ThisWorkbook.Worksheets("xlsMainMenu").OLEObjects(iCount + 2).Object.BackColor = 1000

'\\insert code to run buttons
'ThisWorkbook.VBProject.VBComponents.Item("xlsMainMenu").CodeModule.AddFromString "private sub lbl" & sMemberName & "_click()" & vbCrLf & "msgbox " & sMemberName & vbCrLf & "end sub" & vbCrLf & vbCrLf

Next iCount

'**********************************************************


Everything works fine except for the transparent background!

when I go to the sheet to see how it worked all the buttons and stuff are there but the backgrounds are not transparent. If I look at the properties for any of the controls, it says that they should be transparent but they quiet clearly are not. If I manually change the transparent property it still doesn't change! Of course if I create a text label manually then the transparent property works well...this is really giving me the dirts!...

does anyone have any ideas? t'would help a lot! Email if you want the full code but it really wouldn't do you any good because it accesses a specific database tool that i use to fill the array.

BTW: the last line in the loop above dynamically generates the code to run the labels like buttons if you're interested...hope you guys find a use for that! msgbox command there just for testing.

thanks for any replies that I get.

k.
 
ThisWorkbook.Worksheets("xlsMainMenu").oleobjects(iButtonCount).interior.colorindex = xlcolorindexnone

seems to work.

M :)
 
Mos,

Thanks dude, that did the trick, its all looking good now...

regards

k.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top