![]() |
Listing properties
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 |
Listing properties
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. "Janie" wrote: 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 |
All times are GMT +1. The time now is 11:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com