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: 1
Default Excell VBA - Class Modules problems

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
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
Class Modules mark Excel Programming 7 April 14th 04 10:10 PM
Class Modules ibeetb Excel Programming 1 January 5th 04 10:04 PM
Class modules pk Excel Programming 2 October 3rd 03 03:45 AM
Class Modules vs Modules Jeff Marshall Excel Programming 2 September 28th 03 07:57 PM
Class Modules Siphuncle Excel Programming 2 August 12th 03 06:37 PM


All times are GMT +1. The time now is 02:03 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"