98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel Training and help » Excel VBA object properties
Excel VBA object properties
Resolved · Low Priority · Version 2003
Simon has attended:
Excel VBA Advanced course
Excel VBA object properties
How can I cycle through the properties of an object - names and values - e.g. when I have set up a new class object, to test it I would want to debug.print all the properties and the values they hold, without needing to specifically enter them
RE: Excel VBA object properties
Hi Simon, thanks for your query. Actually, the best way to do this would be to use the Locals window (View - Locals Window). This will show what is being held in memory at each line of code, so once you set an object variable to hold an instance of your class object (e.g. Set myObjectVariable = New clsmyclassobject) and then step through your code (F8) you'll see your object dropped into memory and the Locals Window will give you a plus sign next to the name of the object. Clicking on that plus sign expands a list of all the properties of that object and what values they hold at that point in the code. Try this out and see how you get on.
Hope this helps,
Anthony
RE: Excel VBA object properties
Thanks Anthony.
Yes I believe that would work but really I was trying to get at how I could access and loop through the "collection of properties" - if you like - from my code.
Is that something it's possible to do?
Thanks for the tip though as I think that will be useful to me anyway....
Cheers
Simon
RE: Excel VBA object properties
Hi Simon. There's no index number for the properties of objects, so you can't loop through them like that. One way you might want to consider is to stick the property names into an array when you build the class object and loop through that array.
Hope this helps,
Anthony
Thu 23 Dec 2010: Automatically marked as resolved.
Training information:
See also:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:3D formulas find and replaceAfter you know all the components of a 3D reference, you can change them to suit by using a localised Find and replace crt+f, if need be. |