views:

36

answers:

4

I'm trying to write a vbscript that will export and import the code modules from an Access MDB file to text files.

From within the app I can loop through the DAO Container & Documents and use the 'undocumented' Application.SaveAsText method, but can I do it exeternally?

Your thoughts and ideas are appreciated.

Ben

A: 

It's all COM, so pretty much anything you can do from VBA in the IDE, you can do from a .vbscript file externally.

Set accessApplication = CreateObject("Access.Application")
' then do what you do from the IDE
JeffN825
A: 

You may find this useful : http://stackoverflow.com/questions/2794480/exporting-code-from-microsoft-access

Remou
+1  A: 
Dim objAccess
Dim strFolder
Dim strFile
Dim objModule
strFolder = "C:\Access"
strFile = "foo.mdb"

Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase(strFolder & Chr(92) & strFile)    
For Each objModule In objAccess.CurrentProject.AllModules
    objAccess.SaveAsText 5, objModule.Name, _
        strFolder & Chr(92) & objModule.Name & ".txt"
Next
objAccess.CloseCurrentDatabase
objAccess.Quit
HansUp