Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In module level I create Command Buttons(OLEObjects)
After that I need to get these buttons names when click them In other words i need to have any buttons that call the same subroutin but using variables that depend from the name of clicked button I have next Module & Class Module & they working only if I runs ComNam subroutine exact from itself (If i calling from CheckPivotItemLis subroutine it does'nt work & I have not any warnings or errors!) Plese Help to resolve this moment ! If anybody can suppose other wa please I'll be glad .The focus is that the buttons should be create after certain event (becouse their position depend on list height!) Module "Module 2" : Option Explicit '________________________________________________ Public Sub CheckPivotItemList() Dim i, ym As Integer Dim TT, pr, T1 As String Dim MMM As Variant MMM = Array("E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O" "P") i = 50 ............ For ym = 0 To 11 TT = MMM(ym) ............ T1 = Worksheets("Sheet2").Range(TT & "4").Value Range(TT & Format(i + 5) & ":" & TT & Format(i 10)).Interior.ColorIndex = 15 Worksheets("Sheet2").OLEObjects.Add(ClassType:="Fo rms.CommandButton.1" Link:=False _ , DisplayAsIcon:=False, Left:=Range(TT & Format(i + 6)).Left _ Top:=Range(TT & Format(i + 6)).Top, Width:=Range(TT & Format( + 6)).Width, Height _ :=Range(TT & Format(i + 6)).Height + Range(TT & Format(i 7)).Height).Name = "ComBut" & Format(ym + 1) Worksheets("Sheet2").OLEObjects("ComBut" & Format(ym 1)).Object.Caption = T1 Worksheets("Sheet2").OLEObjects("ComBut" & Format(ym + 1)).Activate Worksheets("Sheet2").Range("A3").Select Next ym Call ComName End Sub '________________________________________________ Sub ComName() Dim Buttoncount As Integer Dim ctl As Object Buttoncount = 0 Worksheets("Sheet2").Range("A3").Select For Each ctl In Worksheets("sheet2").OLEObjects If TypeName(ctl.Object) = "CommandButton" Then Buttoncount = Buttoncount + 1 ReDim Preserve Buttons(1 To Buttoncount) Set Buttons(Buttoncount).ButtonGroup = ctl.Object End If Next ctl End Sub Class Module "Class1": Public WithEvents ButtonGroup As CommandButton '________________________________________________ Public Sub ButtonGroup_Click() MsgBox "Button with " & ButtonGroup.Name & " Name" End Su -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Class Modules | Excel Programming | |||
Class Modules | Excel Programming | |||
Class modules | Excel Programming | |||
Class Modules vs Modules | Excel Programming | |||
Class Modules | Excel Programming |