Allen Browne wrote:
There is an undocumented pair of commands to export a macro as a text file,
and import a text file to a macro. Whether you can modify the text file in
between, I can't say, but if you are interested try SaveAsText and
LoadFromText.
Thanks the following works well:
from win32com.client import Dispatch
from win32com.client import constants
import os.path
exportPath =r'c:\temp\expo rted'
databaseName =r'c:\data\jabu lani asset finance\Current \AmDeals02.mdb'
access=Dispatch ('access.applic ation')
access.Visible= 1
access.OpenCurr entDatabase(dat abaseName,0)
proj = access.CurrentP roject
acConsts={'Tabl es' :constants.acTa ble,
'Queries':const ants.acQuery,
'Modules':const ants.acModule,
'Reports':const ants.acReport,
'Scripts':const ants.acMacro,
'SysRel':None,
'DataAccessPage s':None,
'Relationships' :None
}
saveAsText = access.Applicat ion.SaveAsText
def exportAll():
db=access.Appli cation.CurrentD b()
for container in db.Containers:
containerName = container.Name
print containerName
documents = db.Containers(c ontainerName).D ocuments
if not acConsts.get(co ntainerName,Non e):
continue
for doc in documents:
docName=doc.Nam e
try:
saveAsText(acCo nsts[containerName],
docName,
os.path.join(ex portPath, containerName,
docName+'.txt') )
except Exception,e:
print str(e)
if __name__=='__ma in__':
try:
exportAll()
except Exception,e:
print str(e)
access.Applicat ion.Quit()