Most Valuable Professional


View Jan Karel Pieterse's profile on LinkedIn subscribe to rss feed
Subscribe in a reader

Subscribe to our mailing list

* indicates required
Newsletter Archive

Audit !!!

Check out our RefTreeAnalyser
the ultimate Excel formula auditing tool.

Events


Excel VBA for Financials (Dutch)

Third party tools

Speed up your file

FastExcel
The best tool to optimise your Excel model!

Repair your file

Stellar Phoenix Excel Repair
Best tool to repair corrupt Excel sheets and objects
Home > English site > Articles > Object Lister

Listing an Objects Properties and Methods

Introduction

If you do some VBA programming regularly, you'll be acquainted with the Object browser, which neatly shows you all objects, properties and methods belonging to any object in Excel (or any other library you have referenced in your VBA project).

Whilst this is a tremendous tool to look for information on just a couple of properties I find it not very handy when you e.g. need to get all of an objects properties into your VBA code.

So because I like a challenge I decided to build my own object browser, which is shown to you here.

What does it do?

This tool uses the tlbinf32.dll to fetch data from typelibraries. I grabbed some code from various places (amongst which Chip Pearson's great site and some newsgroup messages like this one) and created a userform with a treeview control (because this is the type of control that can show hierarchical information so nicely).

The help files of tlbinf32.dll can be downloaded here: tlbinf32.zip and the dll can be found here (not sure if you can use the download at will without any licensing issues though).

After downloading the dll it needs to be registered with windows:

Click Start, run and type:

regsvr32 c:\YourPathToThedll\tlbinf32.dll

Click OK. If successful, Windows will tell you it successfully registered the dll.

In its basic state, you select any object in Excel and start the tool, which will show you the first level set of objects, properties and methods of that selection. Here is what the UI looks like after starting the tool whilst you have a chart title selected:


Tool's main window, showing members of a ChartTitle object

And here is the same window after expanding two of the object's members:


Main window after double clicking "Border" and "Font" objects.

As you can see, it is really easy to get a list of all objects and properties of an object.

What's even better is that you can get them into Excel easily. Clicking the "Report" button yields a list of all objects in the current display. Below a portion of those is shown:


Result of clicking "Report".

You can imagine that now it is easy to copy this and paste it into the VBE to quickly create code that sets a lot of properties.

Download

I have made this tool available for download:

Objectlister.zip


Comments

Showing last 8 comments of 64 in total (Show All Comments):

 


Comment by: George Skelton (5/25/2014 4:56:12 PM)

Hi, I'm trying to get this working with 64-bit Excel on Windows 7 Excel 2010. I have tlbinf32.dll saved in C:\Windows\System32, I run regsvr32 from there and get "DllRegisterServer in TLBINF32.DLL succeeded". However when I try to add the Reference in VBA, I browse, select the dll and click open but it won't appear in the Available References list with a checkmark (but there is no error message).

If on the other hand I put tlbinf32.dl in C:\Windows\SysWOW64 and register it there, then I can add the reference but when I try to use it I get Run-time error '429': ActiveX component can't create object

 


Comment by: Jan Karel Pieterse (5/25/2014 5:00:20 PM)

Hi John,

The tlbinf32.dll is 32 bit, which means it will not work with 64 bit Office I'm afraid.

 


Comment by: Lisa Green (4/2/2015 4:48:03 PM)

Hi Jan Karel,

I'm trying to use this to show a UserForms properties.

Is that possible please?

TIA
Lisa

 


Comment by: Jan Karel Pieterse (4/3/2015 4:23:50 PM)

Hi Lisa,

Odd enough I cannot get it to list properties and methods of a userform. I tried:

        Set .ObjectToList = ThisWorkbook.VBProject.VBComponents("ufObjBrowser")


to no avail.

This also does not really give anything helpful:

    Dim uf As ufObjBrowser
    Set uf = New ufObjBrowser
'other code
        Set .ObjectToList = uf


However, as soon as I pass a control I get the associated properties:

    Dim uf As ufObjBrowser
    Set uf = New ufObjBrowser
'other code
        Set .ObjectToList = uf.cmbClose

 


Comment by: Lisa Green (4/3/2015 6:37:51 PM)

Thanks for trying Jan Karel...

Did you get the properties for the userform or the command button?

My aim is to get a list of built in events and then use your performance code in each to log performance and to tell which events fire when.

Lisa

 


Comment by: Jan Karel Pieterse (4/3/2015 7:25:15 PM)

Hi Lisa,

No just the control properties. As far as I recall, the object lister ignores events.

 


Comment by: Lisa Green (4/3/2015 10:28:28 PM)

I'm wondering if it's a problem with "windows"... AFAIK an object like a command button is actually a window while a userform is contained within a window... and no... I'm not sure about what I'm saying!!! :-)

Shame about not listing events... Googling and following links for a loooooooong time is't helping.. :-( I've managed to get lists of events from various sites but some of the lists miss some events that I know exist and some include events I know... I think I know.. are spurious.

It seems the best way so far is to go to the VBE and womanually write down the events from a drop down box!!!

It's an old story I think Jan Karel... They're somewhere ... otherwise the listbox would be up the spout... ut where!!???

Lisa

 


Comment by: Jan Karel Pieterse (4/5/2015 3:04:46 PM)

Hi Lisa,

I'm afraid that is the only way I see right now.

 


Comments are temporarily disabled. We expect commenting to be re-enabled on August 1st, 2015

For simple Excel-related questions I advise this site: www.eileenslounge.com.

For projects and other questions, please contact me using my contact form.