Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Generic Userform class
As I have a lot of userforms I made a generic userform class to get events
of the different forms. This is the code that sets this up: In a Class module called FormClass: ------------------------------------------------------- Option Explicit Public WithEvents objForm As MSForms.UserForm Private Sub objForm_MouseDown(ByVal Button As Integer, _ ByVal Shift As Integer, _ ByVal X As Single, _ ByVal Y As Single) Dim i As Long Dim lContextHelpID As Long Dim arrHelpIDs arrHelpIDs = Array(1000, 1001, 1002, 1004) If Button = 2 Then 'see what form it is For i = 0 To 3 If Forms(i).objForm Is objForm Then lContextHelpID = arrHelpIDs(i) Exit For End If Next If lContextHelpID 0 Then ShowHelp bWebHelp, lContextHelpID End If End If End Sub In a normal module: ------------------------------- Public Forms(22) As New FormClass In the different userform initialize events: ------------------------------------------------------- Set Forms(0).objForm = Me The problem is that I can't get the properties of the userform I want. Ideally I would want the HelpContextID, but the caption would be OK. When I do objForm.HelpContextID I get Runtime error Object doesn't support property or method. When I do objForm.Caption I get an empty string. The above method with looping through the forms array does work, but I would think there should be a better way to do this. RBS |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
refedits in a userform control class | Excel Programming | |||
Generic Macro | Excel Programming | |||
RaiseEvent from a class contained in a 2nd class collection? | Excel Programming | |||
Userform with template class module problem | Excel Programming | |||
Userform with template class module problem | Excel Programming |