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 get all the labels of all forms in array

Need to get all the labels of all forms in an array of custom objects.
This is in connection with control specific help.

Tried like this:

In Class module:
------------------------------

Option Explicit
Public WithEvents objLabel As MSForms.Label

Private Sub objLabel_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)

Dim lContextHelpID As Long

'The following is required because the MouseDown event
'fires twice when right-clicked !!
lClassRightClickCount = lClassRightClickCount + 1

' Do nothing on second firing of MouseDown event
If (lClassRightClickCount Mod 2 = 0) Then
Exit Sub
End If

If Button = 2 Then
On Error Resume Next
lContextHelpID = objLabel.Tag
On Error GoTo 0
If lContextHelpID 0 Then
ShowHelp bWebHelp, lContextHelpID
End If
End If

End Sub


In Normal module:
--------------------------

Public Labels(241) As New LabelClass

Sub AddToLabelClass()

Dim oVBProj As VBProject
Dim oVBComp As VBComponent
Dim i As Long
Dim ctl As MSForms.Control

Set oVBProj = ThisWorkbook.VBProject

For Each oVBComp In oVBProj.VBComponents
If oVBComp.Type = 3 Then
For Each ctl In oVBComp.Designer.Controls
If TypeOf ctl Is MSForms.Label Then
Set Labels(i).objLabel = ctl
i = i + 1
End If
Next
End If
Next

End Sub


I get different error messages and it just doesn't work.
Maybe the trouble is with this:
For Each ctl In oVBComp.Designer.Controls
but haven't found another way yet.


Thanks for any assistance.


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
how do you create labels that hyperlink on forms gbpg Excel Discussion (Misc queries) 2 August 17th 07 02:18 AM
Dialogbox use Pivot or Array Forms? Scott Excel Discussion (Misc queries) 1 May 9th 06 05:05 PM
Excel 2000 - Column labels for forms Abay New Users to Excel 2 August 23rd 05 02:23 AM
Mail merge works with Forms but not with Labels abbaszaidi Excel Discussion (Misc queries) 2 June 29th 05 04:28 PM
Align text for labels in user forms Tim Archer[_2_] Excel Programming 3 January 25th 05 01:00 PM


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