Using Windows environment variables

  • Thread starter Thread starter Christopher Johnson
  • Start date Start date
C

Christopher Johnson

I have a secure Access 2002 database that runs on a
network with everyone accessing it from their own
personal or shared computers running Windows XP. There
is a function that allow the users to import a text file
document from the root C: drive. This all works fine,
howver our IT department is going to begin restricting
access to the C: drive on all computers so I would like
them to be able to do this import with the file on their
desktop. Can I somehow use the Windows environment
varible %USERPROFILE% to do this? If so, how? Right now
I have this:
textfile = "C:\" & inputfilename & ".txt"
I tried this and it did not work:
textfile = "%USERPROFILE%\Desktop\" & inputfilename
& ".txt"

Thanks,
Christopher Johnson
 
Thanks! Exactly what I needed.
Christopher Johnson
-----Original Message-----
"Christopher Johnson"
textfile = "C:\" & inputfilename & ".txt"
I tried this and it did not work:
textfile = "%USERPROFILE%\Desktop\" & inputfilename
& ".txt"

To get to the environment variables, you have to use Environ function. But
a more stable way is to use the APIs.

[ http://www.mvps.org/access/api/api0054.htm ]

CSIDL_DESKTOP or CSIDL_DESKTOPDIRECTORY should work for you.

-- Dev
.
 
Back
Top