Using Access 2003 macros and OutputTo; can't output into the user's My Documents directory

Using Access 2003 macros and OutputTo; can't output into the user's My Documents directory

Post by John Bartl » Thu, 24 Jan 2008 03:27:05


New at macros, trying to send a report to file so it will work on any
machine.

I can't figure out how to send to the $TEMP or $TMP directory, or to
MY DOCUMENTS without knowing the user's name... what do I put in the
OutputFile box when creating a macro to send it to the directories
specified by the system variables $TEMP or $TMP (there's one on every
machine, either will do), or the user's MyDocuments directory, without
hardcoding for a specific user?

Been hacking away at this for a while and am stymied.

Thank you kindly.
 
 
 

Using Access 2003 macros and OutputTo; can't output into the user's My Documents directory

Post by Douglas J. » Thu, 24 Jan 2008 08:34:58

To get the TEMP or TMP folders, use Environ("TEMP") or Environ("TMP")
respectively.

For My Documents, even though this is a macros group, you're best off using
the API calls illustrated in http://www.yqcomputer.com/
"The Access Web".

Yes, it looks intimidating. However, all you need to do is copy everything
between Code Start and Code End and paste it into a new module (not a class
module nor a module associated with a form or report). When you save the
module, do not name it the same as any of the functions or subs within it.
To be save, call it something like mdlFolders.

Once you've done that, all you need to do to get the My Documents folder,
you'd use fGetSpecialFolderLocation(CSIDL_PERSONAL)

--
Doug Steele, Microsoft Access MVP
http://www.yqcomputer.com/
(no private e-mails, please)