Default Path to the Desktop Folder

G

gagecres

Is there a default path to the desktop folder? I was exporting a a form from
one database to another. The database I'm exporting to is on my desktop.
The path is C:\Documents and Settings\Chad\Desktop\Test Database.accdb. I
want to use this saved export in a macro for other people to use, but it is
too specific to my PC. Is there a default path name I can use, like
C:\HOME\Desktop...?
 
A

Allen Browne

Try one of these:
Environ("HOMEPATH") & "\Desktop\"
Environ("USERPROFILE") & "\Desktop\"
 
D

Daniel Pineault

Your desktop directory is based on the currently logged in user name, so no
you can't hard code a value and distribute your db and expect it to work.

That said, you can easily determine the path a run-time and use it as you
please. The code to do so can be found at

http://www.mvps.org/access/api/api0054.htm
http://www.mvps.org/access/api/api0010.htm
http://msdn.microsoft.com/en-us/library/aa140088(office.10).aspx

For the 1st link you'd simply call it
fGetSpecialFolderLocation(CSIDL_DESKTOPDIRECTORY)
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
G

gagecres

Thanks.

Is there a way I can call up a diaglog box or something and let the user
navigate to the file themselves?
 

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