View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Application.Evaluate

If I follow, ButtonGroup_Click() is in Class1 and Command#_Click() is in a
Userform, seems like a strange setup.

When you create Class1 pass a reference of the form, eg

assuming you are creating the class from within the form

' in the form, say in the initialize event
Set c = New Class1
Set c.propFrm = Me
c.aa

' in class1
Private moFrm As Object ' top of module

Public Property Set propFrm(oFrm As Object)
Set moFrm = frm
End Property

Public Sub ButtonGroup_Click()

CallByName moFrm, "CommandButton" & z & "_Click", VbMethod
End Sub

If the reference that store the class is not maintained in the userform, the
class needs to be destroyed before unloading the form, or rather in
particular 'moFrm' needs to be released.

It's difficult to understand what you have overall, but I suspect you might
be better trapping all your button events in a WithEvents class. That means
you only need write the Click event once for all your buttons.

Regards,
Peter T







"Carim" wrote in message
...
Peter,

May I step back a little bit to let you know briefly about the
context ...
A Userform with 20 CommandButtons, which are all managed by a single
procedure :
Public Sub ButtonGroup_Click()
This procedure is located in the single class : Class1
Everything works fine but the very last instruction for a given random
CommandButton which has to act as if the user had clicked himself on a
another CommandButton ...
Hence, this loop I am trying to achieve ...whereby the procedure calls
back itself ...
Hope my explanation is clear enough ...
Cheers
Carim