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: 2,452
Default 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
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
refedits in a userform control class Doug Glancy Excel Programming 10 June 3rd 05 10:39 PM
Generic Macro Steve Excel Programming 3 January 22nd 04 09:03 PM
RaiseEvent from a class contained in a 2nd class collection? Andrew[_16_] Excel Programming 2 January 6th 04 04:22 PM
Userform with template class module problem Tom Ogilvy Excel Programming 1 July 18th 03 09:15 PM
Userform with template class module problem Tom Ogilvy Excel Programming 0 July 17th 03 06:38 PM


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