2
votes

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

1

1 Answers

6
votes

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!