Listing properties

J

Janie

I am looking for something to help with my documentation that I can use to
cycle through the controls on a User Form and list the properties of that
control.

When I read about Properties collection in Help, it appears that only
applies to SmartTags.

I know how to get the value of a property, but I don't want to have to enter
name of every property of each control. I'm looking for something that can
count the number of propeties for that particular control and then list them
and their value out. This is what I have:

Sub ListProps()
Dim intFormCount As Integer, intCounter As Integer

intFormCount = frmMyForm.Controls.Count
For intCounter = 0 To intFormCount - 1
With frmMyForm.Controls(intCounter)
Debug.Print .Name & vbtab & .Font
End With

Next

End Sub

This is what I need:

Sub ListProps()
Dim intFormCount As Integer, intProp As Integer, intCounter As Integer

intFormCount = frmMyForm.Controls.Count
For intCounter = 0 To intFormCount - 1
With frmMyForm.Controls(intCounter)
For intProp=1 to .Properties.Count
Debug.Print .Properties(intProp).Name & vbtab & .Properties(intProp).Value
Next
End With

Next
End Sub


Except that Properties only applies to SmartTags.

Any bright ideas out there?

Many thanks

Janie
 
J

James Snell

In theory you could use Dim ... as object which should allow you to query /
list any child properties; but then you have to be aware that there's
recursion in the object model you're interrogating which would be non-trivial
because of the problems testing it.

That said, I'm not sure that what you are trying to do is actually what you
want to achieve. What you seem to want isn't really documentation, more just
be a print out of a code listing that would be useless to someone who may
have to maintain the code later as they'd just read it from the project/code
in front of them.

If you just want a listing, you'd be better off exporting your userform and
code modules (I *think* you can do that programmatically) and extract what
you want from there as the exported files are only text files.
 
J

Janie

No, you're not quite getting it. I know I can export the CODE -- I've
already done that. But the PROPERTIES of each object on the User Form,
that's what I am after. Exporting the form gives you the properties of the
form itself, but not the properties of the objects on the form. And yes, it
would be useful. (Not to mention required around here). I was trying to
find some way of listing them so I can stick it in my documentation. Example:
a text box has a name, a backcolor, a borderstyle, a caption, a font, a
forecolor, etc etc etc. I want a list with each object's name and the
properties and their values.

For now I'll have to content myself with a screen shot of the Properties
View ... but surely there must be some way to enumerate the properties of a
given object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top