Can I export an Access macro?

M

MikeB

I can't seem to find a way to export an Access macro to a flat
(.txt, .src, .anything) file. Am I just not looking in the right
places?

And after I do export it like that, is there a way to get it back int
another database or is it simply the best to copy it directly from one
database into another?

Thanks.
 
T

Tom Wickerath

Hi Mike,

To export a macro as a text file, try using the undocumented SaveAsText
method. You can use the LoadFromText method to load an object from a text
file. Here are some examples that work in the Northwind sample database (I
used the copy that ships with Access 2003). These commands can be run from
the Immediate Window, which you can open with <Ctrl><G>:

application.saveastext acMacro, "Suppliers", "C:\Temp\SuppliersMacro.txt"

application.loadfromtext acMacro, "SuppliersReloaded",
"C:\Temp\SuppliersMacro.txt"

Note: The entire command goes on one line--it may appear wrapped onto two
lines when you read this reply.
And after I do export it like that, is there a way to get it back int
another database...

I find it easiest to simply import objects from a source DB into the DB that
I have open at the time.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
M

MikeB

Hi Mike,

To export a macro as a text file, try using the undocumented SaveAsText
method. You can use the LoadFromText method to load an object from a text
file. Here are some examples that work in the Northwind sample database (I
used the copy that ships with Access 2003). These commands can be run from
the Immediate Window, which you can open with <Ctrl><G>:

application.saveastext acMacro, "Suppliers", "C:\Temp\SuppliersMacro.txt"

application.loadfromtext acMacro, "SuppliersReloaded",
"C:\Temp\SuppliersMacro.txt"

Note: The entire command goes on one line--it may appear wrapped onto two
lines when you read this reply.


I find it easiest to simply import objects from a source DB into the DB that
I have open at the time.

Tom Wickerath
Microsoft Access MVPhttp://www.accessmvp.com/TWickerath/http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

Thanks Tom. I'll probably just move it between the databases.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top