Excel 2010 VBA - Do you use the Object Browser?

Posted on 2014-08-03
Last Modified: 2014-08-18
I find the object browser of limited usefulness.  Am I the only one?

Some subs/methods are displayed as functions.
It doesn't make sense because a function returns a value and a sub does not.

am I wrong?
Or are there some uses for the object browser that I'm missing.
Question by:brothertruffle880
    LVL 44

    Expert Comment

    by:Martin Liss
    Some subs/methods are displayed as functions.
    What do you mean by that?

    If you open the Object Browser and click on a class like 'ComboBox' it will show you all the events, properties and methods. Clicking on one of them gives helpful information.
    LVL 40

    Expert Comment

    by:Jacques Bourgeois (James Burger)
    It's the best tool you can get to explore what is available in a library, and what are the properties and methods of each class.

    And it still have a usable search mechanism, something that is missing in the last versions of the Office help.

    In many instances, it's a lot faster to search in there than in online help to find the property or method that will do something you need. Once you have found it there, then F1 brings you in Help with more details.

    Author Comment

    HI Martin:
    Range.Activate is also a sub (method) because it does not return a value but it is listed as a function in the browser.

    Or do I have a misunderstanding.  (I'm still on my road to mastery!)
    LVL 40

    Accepted Solution

    This is because Excel is not coded in VB, it is coded in C++. If you explore the Explorer further, you will see that most of the methods that do not return a value are also presented as Function. There are relatively few Sub.

    Without the source code, it is hard to explain exactly why this is so, and the tool that extract the information from the library to present it in the Explorer might also be at cause here, but here are a few possible pointers.

    C++ does not make the distinction that VB makes between a Sub and a Function. In C++, what you call a Sub is a Function declared as type void instead of one of an Integer or a String or whatever. This is hidden for the VB developer because he would not know what a void is.

    C++ also enables you to have many methods with the same name, as long as they do not have the same set of parameters. It's called overloading, something that does not exist in VBA. Some of these overloaded methods might also be declared as internal, once again something that does not exists in VBA. It's an alternative to Private and Public that leaves the method visible inside the application in which it is defined (Excel), but hides it from external applications such as VBA. This might come into play when the Object Browser builds its list.

    If you really make the differentiation between a Sub and a Function in the object model, simply look for a As clause at the end of the declaration that is presented.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
    The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
    This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now