Default directory ?

J

jfp

I have some VBA code like this:

DoCmd.OutputTo acOutputModule, objName, , objName & ".bas"

It works, but the resulting file does not always go to the same
directory. If i have just opened the database, then the file goes to
the directory where the .mdb file is. If i Import something (form,
table, whatever) from a data base in another directory and then run the
above code, the file goes into the directory from which i imported. In
other words, it seems like the most recently (for whatever reason) used
directory becomes the default directory for this command. (This does
NOT happen for "File / Export File" from the VBA menu.) Is there any
way to control this ? Thanks !
 
D

Dan Artuso

Hi,
You can tell it where to output to:
DoCmd.OutputTo acOutputTable,"Articles",acFormatRTF,"C:\articles.doc"
 
J

jfp

OK -- but i want this to be general purpose: I would like the output to
go to the same directory as the database itself (wherever that is, not
known in advance, hence cannot be hard coded.) I assume that there is
some way to dynamically determine this ?
-=-=-=
 
V

Van T. Dinh

If you use A2K or AXP, you can use

CurrentProject.Path

to get the directory where the database resides.

HTH
Van T. Dinh
MVP (Access)
 
C

Chris

If not, CurrentDB.Name and strip off the file name

CurrentDB.Name - Dir(CurrentDb.Name)
 

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