Skip to main content

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.

· 3 min read
View raw
Christophe
Markdown, WSL and Docker lover ~ Insatiable curious.
Cet article existe aussi en français — lire la version française.

Changelog

Latest
GitHub repo cavo789/vbs_access_export is archived (read-only); VBS script remains functional and downloadable.

Export MS Access objects

⚡
TL;DR

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:

>Powershell

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.


Was this article helpful?
Did you try the steps in this article?
🦋 Join the conversation on BlueskyRequires a free Bluesky account to like, repost or comment. This block talks to Bluesky's public API directly from your browser (no cookies, no sign-in) — that means your IP address reaches Bluesky's servers just by this section loading.

Loading comments…