i believe i may know what's going wrong but not sure how to correct it. I
have on the worksheet that is to be used, many embedded controls, rather that
right code for all of them onto that worksheet i use my .xla to class all of
them into groups (checkboxes,command buttons, labels, spin buttons, etc...).
they class when the worksheet is loaded, or activated, etc... when i remove
that classing sub then they event triggers only once, i have a feeling my
coding for that is causeing more than one instance of my class to appear,
Sub classbuttons()
Dim clsCBEvents As Class1
Dim lblbuttons As Class1
Dim sbbuttons As Class1
Dim sbuttons As Class1
Dim shp As Shape
Set mcolEvents = New Collection
Set sbuttonevents = New Collection
Set lblevents = New Collection
Set sbevents = New Collection
For Each shp In ActiveSheet.Shapes
If shp.Type = msoOLEControlObject Then
If TypeOf shp.OLEFormat.Object.Object Is MSForms.CheckBox Then
Set clsCBEvents = New Class1
Set clsCBEvents.cbGroup = shp.OLEFormat.Object.Object
mcolEvents.Add clsCBEvents
End If
If TypeOf shp.OLEFormat.Object.Object Is CommandButton Then
Set sbuttons = New Class1
Set sbuttons.comGroup = shp.OLEFormat.Object.Object
sbuttonevents.Add sbuttons
End If
If TypeOf shp.OLEFormat.Object.Object Is MSForms.Label Then
Set lblbuttons = New Class1
Set lblbuttons.lblGroup = shp.OLEFormat.Object.Object
lblevents.Add lblbuttons
End If
If TypeOf shp.OLEFormat.Object.Object Is MSForms.SpinButton Then
Set sbbuttons = New Class1
Set sbbuttons.sbGroup = shp.OLEFormat.Object.Object
sbevents.Add sbbuttons
End If
End If
Next
End Sub
can i change it anyway so that instead of creating a new instance over and
over again it uses the same class that is existing and maybe creating a
seperate class module for the controls would help???