View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Dump Utility for User form Application

Jim,

You cannot reference a userform in that way, as MyFormName is just a string,
not a userform object.

Unfortunately, you can't just use

For Each ctl In Userforms(MyFormName).Controls

either, as the userforms collection only holds loaded forms, not all forms.

What you have to do is force a load based on string name, then reference
that object, like so


Dim MyFormName As String
Dim oUserForm As Object

MyFormName = InputBox("Enter Form Name")
On Error Resume Next
Set oUserForm = UserForms.Add(MyFormName)
On Error GoTo 0
For Each ctl In oUserForm.Controls

--

HTH

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


"Jim May" wrote in message
news:XOK8f.28506$OM4.10173@dukeread06...
Bob,
I have multiple Userforms in my app;
I have inserted a line in your code

Dim MyFormName as String
MyFormName = Inputbox("Enter Form Name")

On Stepping-thru (even of inception) I get
Compile error
Invalid Qualifier

With MyFormName highlite within the statement:
For Each ctl In MyFormName.Controls

What have I done wrong? Can it be fixed? How?
TIA,
Jim


"Bob Phillips" wrote in message
...
Here's some code

Dim ctl As Object
Dim i As Long

On Error Resume Next
For Each ctl In UserForm1.Controls
i = i + 1
Cells(i, "A").Value = TypeName(ctl)
Cells(i, "B").Value = ctl.Name
Cells(i, "C").Value = ctl.Caption
Cells(i, "D").Value = ctl.Value
Next ctl


--

HTH

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


"Jim May" wrote in message
news:zdH8f.28498$OM4.3029@dukeread06...
Is there an excel utility that will "dump" to a sheet (with headings)

the
various Controls (name, caption, etc...) currently in use in a

Project's
Forms folder? If so, where would I find such? I searched Google

without
any
luck.
TIA,