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 How to access group buttons in Class Module?


I have a Class Event that controls a group of CommandButtons and set
up as follows in a Class Module (named BnClass).

Public WithEvents ButtonGroup As Msforms.CommandButton
Sub ButtonGroup_Click()

<code

End sub

I have no difficulty accessing any of the 60 buttons involved from the
Userform module or a general module but in either instance only through
the facility of a
*For each ... Next* construct which enables me to tap into the
controls collection.

Now, my problem is to get the right syntax to access *only one* of the
buttons without having to resort to For each ... next Loop. For
example, in the Userform module, I attempted (and crashed!) in a bid
to re-assign an attribute of CommandButton20 from the group to another
control (CmdPivot). None of the following worked with each throwing up
"Object Required" error.

Me.CmdPivot.BackColor = BnClass.ButtonGroup(CommandButton20).BackColor
Me.CmdPivot.BackColor = BnClass.(CommandButton20).BackColor
Me.CmdPivot.BackColor = CommandButton20.BackColor

Can someone kindly point me the way?

[ I want to avoid the verbosity of using a loop as in: For each ctl
in Me.Controls
If Typename(ctl) ="CommandButton" Then
If ctl.Name="CommandButton20 Then
< code
End if
End if
Next
This is because I have a number of such and similar assignments to make
here and there (18 in total) and would imagine that applying looping
each time will be unwieldy.]


Thanks

Myles


--
Myles
------------------------------------------------------------------------
Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746
View this thread: http://www.excelforum.com/showthread...hreadid=492389

 
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
Reference Class Module in Access from Excel [email protected] Excel Programming 2 September 28th 05 09:55 AM
Class module in VBA romkeys Excel Programming 1 August 19th 04 06:20 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 02:09 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"