Default directory ?

  • Thread starter Thread starter jfp
  • Start date Start date
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 !
 
Hi,
You can tell it where to output to:
DoCmd.OutputTo acOutputTable,"Articles",acFormatRTF,"C:\articles.doc"
 
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 ?
-=-=-=
 
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)
 
If not, CurrentDB.Name and strip off the file name

CurrentDB.Name - Dir(CurrentDb.Name)
 
Back
Top