Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Utilizing a Class Module

Using Excel 2002 - My active sheet has 20 command
buttons. I would like to use a class module to make their
events more efficient.

I have created a class module called "BtnClass". I've
added the following code to that module:

Public WithEvents ButtonGroup As CommandButton
Private Sub ButtonGroup_Click()
MsgBox ButtonGroup.Caption
End Sub

I have added a module called "module1" and have added this
code to it:

Dim Buttons() As New BtnClass
Sub EnableBtnEvents()
Dim ButtonCount As Integer
Dim Ctl As OLEObject
ButtonCount = 0
For Each Ctl In ActiveSheet.OLEObjects
ButtonCount = ButtonCount + 1
ReDim Preserve Buttons(1 To ButtonCount)
Set Buttons(ButtonCount).ButtonGroup = Ctl
Next Ctl
End Sub

I can't seem to get it to work. What am I doing wrong?
Thanks for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Utilizing a Class Module

Jim

Change this line

Set Buttons(ButtonCount).ButtonGroup = Ctl


to

Set Buttons(ButtonCount).ButtonGroup = Ctl.Object

I assume you were getting a Type Mismatch error, but if it's something else,
say why it's not working.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Utilizing a Class Module

Dick - that's got it going. Thanks so much.

-----Original Message-----
Jim

Change this line

Set Buttons(ButtonCount).ButtonGroup = Ctl


to

Set Buttons(ButtonCount).ButtonGroup = Ctl.Object

I assume you were getting a Type Mismatch error, but if

it's something else,
say why it's not working.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com


.

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
CLASS MODULE & SIMPLE MODULE FARAZ QURESHI Excel Discussion (Misc queries) 1 September 7th 07 09:32 AM
let and get in class module Doug Glancy Excel Programming 3 June 30th 04 02:30 PM
Class Module Todd Huttenstine Excel Programming 2 May 21st 04 11:17 PM
Class module David Excel Programming 4 December 31st 03 01:58 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


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