2

In the Object Browser window there's a list of the libraries being used.

By default it comes with:

  • Excel (Microsoft Excel version Object Library)
  • Office (Microsoft Office version Object Library)
  • stdole (OLE Automation)
  • VBA (Visual Basic For Applications)
  • VBAProject

They can also be found by looping the references of the VBProject using the VBIDE library (Microsoft Visual Basic for Applications Extensibility version) except for VBAProject.

Is VBAProject a library, a special keyword, or something else? Couldn't find any documentation on it.

I would guess it's part of the VBA library as well but it doesn't seem to appear under the references.

Dim ref As VBIDE.Reference

For Each ref In Application.VBE.VBProjects(1).References
  MsgBox ref.Name & " - " & ref.Description
Next

VBAProject has the code names of the workbooks and sheets.

I also couldn't remove manually nor with code the Excel and VBA libraries to test if VBAProject would disappear (Office and stdole are removable).

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
user7393973
  • 2,270
  • 1
  • 20
  • 58

1 Answers1

6

It's not a keyword, it's an identifier representing the COM type library of your VBA project.

When a VBA project is compiled, a COM type library is internally created - the Object Browser is simply listing all type libraries currently loaded in the editor, and that includes the library for your own project.

That's why it's listing the "code names" of all document modules - if you added a standard module, it would be there as well:

object browser showing classes in VBAProject

And if you rename your project (recommended, especially for any Excel add-in project), then it's not VBAProject anymore:

members of MyAwesomeProject


#FunFacts: when the VBE first initializes and a new VBA project is created, it's called VBProject for a few milliseconds (VB6 default project name) - the VBE then renames it to VBAProject ...this used to cause problems with Rubberduck!

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
  • Nice answer Mathieu. Side question if you not too bothered. Can you explain a little bit about COM type library in the answer. Reading the documenation (as a foreigner) is a bit confusing. Looks like it defines which object properties and methods can be used through other applications at run-time. Does that include non-VBA ones for example? – JvdV Oct 01 '19 at 15:43
  • Thanks for the in depth explanation and the tip (I have never renamed any project). As I understood `VBAProject` is a loaded/running library that as the name obviously says, is the VBA project itself. – user7393973 Oct 01 '19 at 15:43