excel vba object properties
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Excel VBA object properties

Excel VBA object properties

resolvedResolved · Low Priority · Version 2003

replyReply Thu 9 Dec 2010, 15:50Delegate Simon said...

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

For upcoming training course dates see: Pricing & availability

replyReply Wed 15 Dec 2010, 12:47Trainer Anthony said...

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

replyReply Thu 16 Dec 2010, 10:32Delegate Simon said...

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

replyReply Thu 16 Dec 2010, 18:11Trainer Anthony said...

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.

 

Please browse our web site to find out more about
excel consulting and other Microsoft training courses.

Excel tip:

Closing all your workbooks Quickly

Hold the SHIFT key down and using the mouse click on the file menu, it will now now CLOSE ALL rather than close. This closes all workbooks down but still leaves the application open.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard