View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.programming
Jim May Jim May is offline
external usenet poster
 
Posts: 430
Default Dump Utility for User form Application

Bob, thanks..
I had replace the original (2) Subs from your 1st mailing
with the (1) Sub from your 2nd mailing (not knowing you
only had the 1st Sub in your 2nd mailing)... Sorry,,
It works like a charm!!
Jim

"Bob Phillips" wrote in message
...
Jim,

It's missing the sub altogether. Just tagit at the end

Private Sub myControls(ByVal FormName As String, sh As Worksheet, _
ByRef i As Long)
Dim ctl As Object
Dim oUserForm As Object

On Error Resume Next
Set oUserForm = UserForms.Add(FormName)
If Not oUserForm Is Nothing Then
sh.Cells(i, "a").Value = FormName
For Each ctl In oUserForm.Controls
i = i + 1
sh.Cells(i, "B").Value = TypeName(ctl)
sh.Cells(i, "C").Value = ctl.Name
sh.Cells(i, "D").Value = ctl.Caption
sh.Cells(i, "E").Value = ctl.Value
Next ctl
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim May" wrote in message
news:9z59f.34991$OM4.25401@dukeread06...
Here you go (from the top of Module1):

#Const EarlyBound = False

#If Not EarlyBound Then
Const vbext_ct_StdModule As Long = 1
Const vbext_ct_ClassModule As Long = 2
Const vbext_ct_MSForm As Long = 3
#End If

Sub ShowMyControls()
'----------------------------------------------------------------
#If Not EarlyBound Then
Dim ovbmod As Object
#Else
Dim ovbmod As VBIDE.VBComponent
#End If
Dim i As Long
Dim sh As Worksheet

On Error Resume Next
Set sh = Worksheets("Report of Controls")
If sh Is Nothing Then
Set sh = Worksheets.Add
sh.Name = "Report of Controls"
Else
sh.Cells.ClearContents
sh.Activate
End If
With sh
.Range("A4").Value = "FormName"
.Range("B4").Value = "TypeControl"
.Range("C4").Value = "ControlName"
.Range("D4").Value = "ControlCaption"
.Range("E4").Value = "TabIndex"
.Range("F4").Value = "ControlValue"
.Range("A4:F4").Font.Bold = True
.Range("A4:F4").HorizontalAlignment = xlCenter
.Range("A5").Select
End With
i = 4

With ActiveWorkbook.VBProject
For Each ovbmod In .VBComponents
Select Case ovbmod.Type
Case vbext_ct_StdModule:
Case vbext_ct_MSForm:
i = i + 1
myControls ovbmod.Name, sh, i
Case vbext_ct_ClassModule:
End Select
Next ovbmod
End With

End Sub

"Bob Phillips" wrote in message
...
Jim,

It sounds that the myControls sub and the call are out of sync. Can you
post
all of the code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim May" wrote in message
news:RC49f.34200$OM4.4631@dukeread06...
Embarrisingly, I just this morning tried the ALL Uforms
dump, yet got compile error @ line:
(Sub or Function not Defined)
myControls ovbmod.Name, sh, i << with "myControls" being highlighted

What can be done (to proceed)?
Jim

"Bob Phillips" wrote in message
...
Hi Jim,

The extra code that I gave you uses the Microsoft Visual Basic For
Application Extensibility library. The code uses some constants in

that
library, so you can set a reference to that library in the VBIDE, or
you
can
use late binding where you replace the constants with the actual

value.
What
I do is add code similar to the lines that you mention that do
conditional
compilation, #If Not EarlyBound Then, and creates my own constants

with
the
same names and the appropriate values.

What this all means is that by including this code at the start of

the
module, after any Option declarations but before any procedures, I

can
either have my code late binding by doing nothing else, or I can
have
my
code early binding, by adding a reference to that library and by

adding
another line before these lines of

#Const EarlyBound = True

To be absolutely factual, the code should read

#Const EarlyBound = False

#If Not EarlyBound Then
Const vbext_ct_StdModule As Long = 1
Const vbext_ct_ClassModule As Long = 2
Const vbext_ct_MSForm As Long = 3
#End If


'----------------------------------------------------------------
Sub ShowMyControls()
'----------------------------------------------------------------
#If Not EarlyBound Then
Dim ovbmod As Object
#Else
Dim ovbmod As VBIDE.VBComponent
#End If
Dim i As Long
Dim sh As Worksheet

On Error Resume Next
Set sh = Worksheets("Report of Controls")
If sh Is Nothing Then
Set sh = Worksheets.Add
sh.Name = "Report of Controls"
Else
sh.Cells.ClearContents
sh.Activate
End If
With sh
.Range("A4").Value = "FormName"
.Range("B4").Value = "TypeControl"
.Range("C4").Value = "ControlName"
.Range("D4").Value = "ControlCaption"
.Range("E4").Value = "ControlValue"
.Range("A4:E4").Font.Bold = True
.Range("A4:E4").HorizontalAlignment = xlCenter
.Range("A5").Select
End With
i = 4

With ActiveWorkbook.VBProject
For Each ovbmod In .VBComponents
Select Case ovbmod.Type
Case vbext_ct_StdModule:
Case vbext_ct_MSForm:
i = i + 1
myControls ovbmod.Name, sh, i
Case vbext_ct_ClassModule:
End Select
Next ovbmod
End With

End Sub

I can then just flip the constant as required
--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim May" wrote in message
news:7mT8f.31495$OM4.7158@dukeread06...
Bob,
Thanks for your help on this "project";
Sorry for the "back and forth" action,,
But you helped me immensely..

Haven't totally utilized you last suggestion which
reports on ALL userforms (cause I didn't know
what to do with the lines:)

#If Not EarlyBound Then
Const vbext_ct_StdModule As Long = 1
Const vbext_ct_ClassModule As Long = 2
Const vbext_ct_MSForm As Long = 3
#End If

appearing before the normal code.
Can you specify (what to do with it - with explaination)..
Jim May