DMW logo
contact@consultdmw.com

How to List All Modules and Macros in an Access Database

How to create VBA functions to list in the Immediate Window of its Visual Basic Editor all the modules and macros of a Microsoft® Access database.

Last updated on 2021-10-21 by David Wallis.


VBA Function to List All Modules

This function lists all the modules in the database in which you execute it:

Function fnDmwListAllModules() As String

On Error GoTo errHandler

Dim msg$

Dim obj As AccessObject, db As Object


Set dB = Application.CurrentProject

For Each obj In db.AllModules

Debug.Print obj.Name

Next obj

msg$ = "Module listing complete"


procDone:

fnDmwListAllModules = msg$

Exit Function

errHandler:

msg$ = Err.Number & " " & Err.Description

Resume procDone

End Function


VBA Function to List All Macros

Don Hirst suggested I include a function to list all macros in a database. And he kindly provided me with one. Here it is:

Function dvhListAllMacros() As String

On Error GoTo errHandler

Dim msg$

Dim obj As AccessObject, db As Object

Set dB = Application.CurrentProject

For Each obj In db.AllMacros

Debug.Print obj.Name

Next obj

msg$ = "Macros listing complete"


procDone:

dvhListAllMacros = msg$

Exit Function

errHandler:

msg$ = Err.Number & " " & Err.Description

Resume procDone

End Function

Thanks again Don.


How to Run Your Function

To execute the function, copy and paste the code into a module in your database’s Visual Basic Editor.

Then in its Immediate Window type ?NameOfFunction() and press Enter. Don’t omit the leading question mark.


Your Support for DMW TIPS

Please support this website by making a donation to help keep it free of advertising and to help towards cost of time spent adding new content.

To make a contribution by PayPal in GBP (£ sterling) —

To make a contribution by PayPal in USD ($ US) —

Thanks, in anticipation.


Disclaimer

DMW Consultancy Ltd does not accept any liability for loss or damage to data to which any techniques, methods or code included in this website are applied. Back up your data; test thoroughly before using on live data.

“Lists are how I parse and manage the world.”

Adam Savage