View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default get HelpContextID's or Tags of all userforms

TypeName(ctl)

--
Regards,
Tom Ogilvy


"RB Smissaert" wrote in message
...
I got this mostly worked out now except I need the type of control as

well:

Sub tester()

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

Set oVBProj = ThisWorkbook.VBProject

On Error Resume Next

For Each oVBComp In oVBProj.VBComponents
If oVBComp.Type = 3 Then
For Each ctl In oVBComp.Designer.Controls
If ctl.Tag < "" Or ctl.HelpContextID 0 Then
MsgBox "Tag:" & vbTab & ctl.Tag & _
vbCrLf & _
"HelpID:" & vbTab & ctl.HelpContextID, , _
ctl.Name
End If
Next
End If
Next

End Sub

It doesn't look you can get the control type from

oVBComp.Designer.Controls

RBS

"Peter T" <peter_t@discussions wrote in message
...
In fact I need to list all the HelpContextID's and Tags of all the

possible
controls of all the Userforms


For each ctl In oVBComp.Designer.Controls
debug.? ctl.Tag, ctl.HelpContextID
Next

FWIW, you can also "permanently" write these properties subject to then
saving the project.

Regards,
Peter T


"RB Smissaert" wrote in message
...
Hi Peter,

Thanks, will give that a try.
In fact I need to list all the HelpContextID's and Tags of all the

possible
controls of all the Userforms
in the project.
This in connection with a big html help (WebHelp) file.
So I will need 2 For Each loops.

RBS


"Peter T" <peter_t@discussions wrote in message
...
Hi Bart,

Try inserting the following after your "If oVBComp.Type = 3 Then"

For Each p In oVBComp.Properties
'Debug.Print p.Name
If p.Name = "Tag" Then
MsgBox p.Value, , oVBComp.Name
End If
If p.Name = "HelpContextID" Then
MsgBox p.Value, , oVBComp.Name
End If
Next

Of course if you could get same from the userform object though that

means
loading it.

Regards,
Peter T

"RB Smissaert" wrote in message
...
Is there a way to get all the HelpContextID's or Tags of all the
userforms
in a project?
I can get all the names of all the forms, but sofar no success to

get
the
HelpContextID's or Tags.

Sub test()

Dim oVBProj As VBProject
Dim oVBComp As VBComponent

Set oVBProj = ThisWorkbook.VBProject

On Error Resume Next

For Each oVBComp In oVBProj.VBComponents
If oVBComp.Type = 3 Then
MsgBox oVBComp.Name
End If
Next

End Sub

Thanks for any advice.


RBS