Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel vba object properties

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

Excel VBA object properties

ResolvedVersion 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.

Excel tip:

Applying and removing border from cell in Excel 2010

Did you know the shortcut key for applying and removing the outline border for a cell?

CTRL+SHIFT+& Applies the outline border to the selected cells.
CTRL+SHIFT_ Removes the outline border from the selected cells.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.