By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

Opening macros in design mode with code

P: n/a
Hi

I am writing a tool to extract form, report, properties to a
XML format for further analysis (cross referencing etc) using Python.

Reports and Forms can be accessed using AllForms, AllReports
and DoCmd to open them in design mode but
Although there is a collection "AllMacros" there does not seem
to be a way using DoCmd to gain access to the macros collection.

Any help appreciated.

Aug 20 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"neib" <ge*******@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
>
I am writing a tool to extract form, report, properties to a
XML format for further analysis (cross referencing etc) using Python.

Reports and Forms can be accessed using AllForms, AllReports
and DoCmd to open them in design mode but
Although there is a collection "AllMacros" there does not seem
to be a way using DoCmd to gain access to the macros collection.

Any help appreciated.

Aug 20 '06 #2

P: n/a
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\exported'
databaseName =r'c:\data\jabulani asset finance\Current\AmDeals02.mdb'

access=Dispatch('access.application')
access.Visible=1
access.OpenCurrentDatabase(databaseName,0)
proj = access.CurrentProject

acConsts={'Tables' :constants.acTable,
'Queries':constants.acQuery,
'Modules':constants.acModule,
'Reports':constants.acReport,
'Scripts':constants.acMacro,
'SysRel':None,
'DataAccessPages':None,
'Relationships':None
}

saveAsText = access.Application.SaveAsText

def exportAll():
db=access.Application.CurrentDb()
for container in db.Containers:
containerName = container.Name
print containerName
documents = db.Containers(containerName).Documents
if not acConsts.get(containerName,None):
continue
for doc in documents:
docName=doc.Name
try:
saveAsText(acConsts[containerName],
docName,
os.path.join(exportPath, containerName,
docName+'.txt'))
except Exception,e:
print str(e)

if __name__=='__main__':
try:
exportAll()
except Exception,e:
print str(e)
access.Application.Quit()

Aug 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.