VBE_Extras catch-up #2: Listing all declarations
- John
- 3 days ago
- 3 min read
When I first made VBE_Extras available for download, it contained a whole load of functionality that I never wrote blog posts about. I'm now setting that right for a few of the core areas of that functionality.
When I say "declaration" I mean something that has been declared somewhere in a VBA Project ... for example:
In a procedure or property, you can have:
Parameters (declared in the procedure / property signature)
Variables (declared with the Dim keyword)
Constants (declared with the Const keyword)
Statics (declared with the Static keyword)
Line labels (which are followed by a colon)
In a Module, you can have:
Procedures (declared with the Sub or Function keyword)
Properties (declared with the Property keyword in combination with Get, Let or Set)
Events (declared with the Event keyword)
Variables ... sometimes called Fields when declared at the Module level (declared with the Dim keyword)
Constants (declared with the Const keyword)
Enums (declared with the Enum keyword ... technically, Enums are Project level ... but, in VBA, they are declared in Modules)
Types (declared with the Type keyword)
... and both Enums and Types have there own members declared within them
Windows API Functions (declared with the Declare keyword in combination with either Sub or Function and, since Office 2010, the PtrSafe keyword)
Conditional compilation constants (declared with the #Const keyword ... you can declare these within a procedure or property ... but they are always Module-level)
In a VBA Project, you can have:
Modules (Standard, Class, UserForm and Document ... Document Modules are, for the host applications that VBE_Extras supports: in Excel, ThisWorkbook and Sheets; in Word, ThisDocument; in Access, Forms and Reports; in Outlook, ThisOutlookSession; in PowerPoint, Slides)
Interfaces (which are actually just Class Modules that follow a specific structure)
Conditional Compilation Arguments (declared in the General tab of the Project Properties dialog)
Then there are also Controls (in UserForms, Forms, Sheets etc) and, of course, the VBA Project itself is a declaration.
VBE_Extras will list all of these. It will do so for:
The declarations that are declared in a specific procedure or property ... using the Declarations > In this procedure / property command
The declarations that are declared in a specific Module ... using the Declarations > In this Module command
The declarations that are declared in a specific Project ... using the Declarations > In this Project command
... for each of these, "this" means the one that is active: for procedures and properties, the active one is the one that your cursor is within; the active Module is the one being displayed in the active code pane (ie that has the keyboard focus); the active Project is the one that the active Module is within
And you can get all declarations or you can filter for a specific type of declaration ... for example, all variables in a procedure, all events in a Module etc. The list of declarations is then displayed in a dialog like this ...

... which is an example of all declarations in a Module. Or like this ...

... which is an example of all declarations in a procedure.
You will see from the images that you can then filter / search within the list of declarations.
Also, for any selected declaration, you can view it in a text dialog; get a list of the references of that declaration (i.e. a list of every place that declaration is used); or you can 'go to' it (ie VBE_Extras will move the cursor / selection to the declaration).
You can also get a CSV of all of the declarations if useful.

Comments