Export MS Access objects
Easily version control your MS Access database! Export all VBA code, forms, modules, queries, and reports to flat files using a simple VBS script for GitHub integration.
This article is part of the VBA & MS Office automation series:
- MS Office - How to create a ribbon in Excel
- MS Excel - How to call a SOAP web service
- How to optimize an existing MS Access database
- VBS - Retrieve the list of fields in a MS Access Database
- VBS - Auto update script
- Microsoft Outlook - VBA - Save emails as PDF
- VBS - Get list of files and generate a CSV
- MS Office - Load dropdown from Excel's range
- Export MS Access objects
- MS Excel - Get the list of references used in your modules
Changelog

This article introduces a VBS script for exporting all objects—forms, modules, queries, reports, and macros—from a Microsoft Access database into individual text-based files. This process allows developers to easily version control their Access application's source code using tools like Git and GitHub. The script automatically organizes the exported files into a structured src folder, creating a separate file for each object, making it simple to track changes and maintain a history of the database's design and logic.
A long time ago, in a previous life, I developed a lot of MS Access databases and unlike modern tools, it wasn't possible to version the code (modules, macros, queries, etc.) in a tool like Github.
These objects are an integral part of the database in the same way as the tables and their data. Everything is stored inside the .mdb format (or .mda or .accdb). If you want to version them, you must first extract them.
Two other MS Access articles on this blog: VBS - Retrieve the list of fields in a MS Access Database to audit the structure, and How to optimize an existing MS Access database to act on the results.
Let's look at how to do this.
Sample
By running cscript vbs_access_export.vbs C:\Christophe\db1.mdb in a DOS console, you'll get this:
Once finished, you'll have a subfolder called src with one file by object so, indirectly, you've a backup of your code 👌.
Description
My https://github.com/cavo789/vbs_access_export VBS script will export all code objects (forms, macros, modules, queries and reports) from a MS Access database / application to flat files on your disk.
This way, you'll get a quick backup of your code and you'll be able to synchronize your code on a versioning platform like GitHub.
The script will start MS Access (in hidden mode), open the specified database, process every code object and export them, one by one, in a \src\your_database.mdb folder.
The src folder will be automatically created if needed and you'll find a subfolder having the same name as your file (so you can have more than one exported file in the same src folder).
Install
Just get a copy of the https://github.com/cavo789/vbs_access_export VBS script, perhaps the .cmd too (for your easiness) and save them in the same folder as your database.
Usage
Just edit the .cmd file and you'll see how it works: you just need to run the .vbs with one parameter, the name of your database — the same command already shown at the top of this article.
Conclusion
A single VBS script turns forms, modules, queries, reports and macros — everything that used to live only inside the .mdb/.accdb file — into flat files you can commit to GitHub, diff, and track like any other codebase. Working with VBA-heavy files in general? See also MS Excel - Get the list of references used in your modules, How to optimize an existing MS Access database and VBS - Retrieve the list of fields in a MS Access Database.
This article is part of the VBA & MS Office automation series:
- MS Office - How to create a ribbon in Excel
- MS Excel - How to call a SOAP web service
- How to optimize an existing MS Access database
- VBS - Retrieve the list of fields in a MS Access Database
- VBS - Auto update script
- Microsoft Outlook - VBA - Save emails as PDF
- VBS - Get list of files and generate a CSV
- MS Office - Load dropdown from Excel's range
- Export MS Access objects
- MS Excel - Get the list of references used in your modules
Loading comments…
