DMW logo
contact@consultdmw.com

How to List All Modules and Macros in an Access Database

Last updated by David Wallis on 2024-05-30.


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 Functions

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 ?fnDmwListAllModules() or ?dvhListAllMacros() 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

David Wallis 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