Codium Logo Codium Logo
  • Services
  • Industries
  • Our Work
  • About
  • Blog
Blog

Microsoft Access Source Control

25 June 2012
Source control for Microsoft Access 2003 - 2011

' Usage:
'  CScript decompose.vbs "input file" "path"

' Converts all modules, classes, forms and macros from an Access Project file (.adp) input file to ' text and saves the results in separate files to path. Requires Microsoft Access. '

Option Explicit

const acForm = 2 const acModule = 5 const acMacro = 4 const acReport = 3

' BEGIN CODE Dim fso Set fso = CreateObject("Scripting.FileSystemObject")

dim sADPFilename If (WScript.Arguments.Count = 0) then MsgBox "Bitte den Dateinamen angeben!", vbExclamation, "Error" Wscript.Quit() End if sADPFilename = fso.GetAbsolutePathName(WScript.Arguments(0))

Dim sExportpath If (WScript.Arguments.Count = 1) then sExportpath = "" else sExportpath = WScript.Arguments(1) End If

exportModulesTxt sADPFilename, sExportpath

If (Err <> 0) and (Err.Description <> NULL) Then MsgBox Err.Description, vbExclamation, "Error" Err.Clear End If

Function exportModulesTxt(sADPFilename, sExportpath) Dim myComponent Dim sModuleType Dim sTempname Dim sOutstring

dim myType, myName, myPath, sStubADPFilename myType = fso.GetExtensionName(sADPFilename) myName = fso.GetBaseName(sADPFilename) myPath = fso.GetParentFolderName(sADPFilename)

If (sExportpath = "") then sExportpath = myPath & "\Source\" End If sStubADPFilename = sExportpath & myName & "_stub." & myType

WScript.Echo "copy stub to " & sStubADPFilename & "..." On Error Resume Next fso.CreateFolder(sExportpath) On Error Goto 0 fso.CopyFile sADPFilename, sStubADPFilename

WScript.Echo "starting Access..." Dim oApplication Set oApplication = CreateObject("Access.Application") WScript.Echo "opening " & sStubADPFilename & " ..." oApplication.OpenAccessProject sStubADPFilename

oApplication.Visible = false

dim dctDelete Set dctDelete = CreateObject("Scripting.Dictionary") WScript.Echo "exporting..." Dim myObj For Each myObj In oApplication.CurrentProject.AllForms WScript.Echo " " & myObj.fullname oApplication.SaveAsText acForm, myObj.fullname, sExportpath & "\" & myObj.fullname & ".form" oApplication.DoCmd.Close acForm, myObj.fullname dctDelete.Add "FO" & myObj.fullname, acForm Next For Each myObj In oApplication.CurrentProject.AllModules WScript.Echo " " & myObj.fullname oApplication.SaveAsText acModule, myObj.fullname, sExportpath & "\" & myObj.fullname & ".bas" dctDelete.Add "MO" & myObj.fullname, acModule Next For Each myObj In oApplication.CurrentProject.AllMacros WScript.Echo " " & myObj.fullname oApplication.SaveAsText acMacro, myObj.fullname, sExportpath & "\" & myObj.fullname & ".mac" dctDelete.Add "MA" & myObj.fullname, acMacro Next For Each myObj In oApplication.CurrentProject.AllReports WScript.Echo " " & myObj.fullname oApplication.SaveAsText acReport, myObj.fullname, sExportpath & "\" & myObj.fullname & ".report" dctDelete.Add "RE" & myObj.fullname, acReport Next

WScript.Echo "deleting..." dim sObjectname For Each sObjectname In dctDelete WScript.Echo " " & Mid(sObjectname, 3) oApplication.DoCmd.DeleteObject dctDelete(sObjectname), Mid(sObjectname, 3) Next

oApplication.CloseCurrentDatabase oApplication.CompactRepair sStubADPFilename, sStubADPFilename & "_" oApplication.Quit

fso.CopyFile sStubADPFilename & "_", sStubADPFilename fso.DeleteFile sStubADPFilename & "_"

End Function

Public Function getErr() Dim strError strError = vbCrLf & "----------------------------------------------------------------------------------------------------------------------------------------" & vbCrLf & _ "From " & Err.source & ":" & vbCrLf & _ " Description: " & Err.Description & vbCrLf & _ " Code: " & Err.Number & vbCrLf getErr = strError End Function



* Credits go to Oliver over on stackoverflow.com for this great solution.
2012
Keep reading

More from the blog

Has your business outgrown Excel? Seven signs, and what to do about each one
15 Oct 2026

Has your business outgrown Excel? Seven signs, and what to do about each one

Spreadsheets fail slowly, so nobody notices the day they stop being a tool and start being the system. Here are the signs, the fix...

What has changed in custom software development over the last 12 months
2 Sep 2026

What has changed in custom software development over the last 12 months

Software development continues to evolve quickly, but the last 12 months have seen some particularly significant changes in the wa...

How do you know which asset is about to fail before it does?
30 Jul 2026

How do you know which asset is about to fail before it does?

The failure was there in the data for three inspections before the breakdown. Nobody could see it because the data was spread acro...

All articles

Want to talk about your own project?

Tell us what's slowing your business down. One of our digital strategists will talk it through with you.

Get in touch Call 1300 887 103
Codium Logo
Codium Pty Ltd.
Ground Floor, 207 Greenhill Road
Eastwood, 5063
Adelaide, South Australia
  • 1300 887 103
  • sales@codium.com.au

Development

  • Software Development
  • Mobile Apps
  • Software Integration
  • Hardware Integration
  • Microsoft Access
  • Replace Spreadsheets

Managed Services

  • Software Takeover
  • Software Support (SLA)
  • Managed Hosting
  • Private AI Hosting
  • On-Premise AI

AI

  • AI Consulting
  • AI Reporting

Strategy

  • Technology Partner
  • UI / UX Design
  • Due Diligence (M&A)
  • Why Projects Succeed
  • What Software Costs
  • What AI Consulting Costs

Technologies

  • PHP · Laravel
  • JavaScript · Vue.js
  • AWS

Company

  • About Us
  • Industries
  • Our Work
  • Blog
  • Careers
  • Contact Us
  • Customer Feedback
  • Remote Support

© Codium Pty Ltd. All Rights Reserved.

  • Terms of Business
  • Privacy Policy
  • Quality Policy
  • Security Policy
  • Customer Experience Charter
Back Top
Codium
Services
All services Strategy
  • Technology Partner
  • UI / UX Design
  • Technology Due Diligence
  • Why Projects Succeed
  • What Software Costs
  • What AI Consulting Costs
Development
  • Software Development
  • Mobile App Development
  • Software Integration
  • Hardware Integration
  • Microsoft Access Databases
  • Replace Spreadsheets
Managed services
  • Software Takeover
  • Software Support (SLA)
  • Managed Hosting
  • Private AI Hosting
  • On-Premise AI
AI
  • AI Consulting
  • AI Reporting
Industries
All industries
  • Construction
  • Finance
  • Government
  • Health
  • Insurance
  • Manufacturing
  • Mining
  • Retail & E-commerce
  • Transport & Logistics
Our Work About Blog
Get in touch Call 1300 887 103