Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use System Variables?

Status
Not open for further replies.

vbmanchris

Programmer
Apr 29, 2002
3
US
Hello,

I am trying to use a system variable to determine and set the path to an export file that my VBA code is creating. What variables can be used in VBA to set the path to the user's desktop, or the Windows directory, for example?

Obviously, "C:\Windows\Desktop" isn't going to work on W2K or NT, like it does on Win98.

Thanks,

Chris
 
I've been using this for some time now on NT 4.0

"C:\Winnt\profiles\" & Environ$("UserName") & "\Desktop"

The Environ$("UserName") function will return the username of the person logged in at the time.

Assuming of course the path to your desktop is
"C:\Winnt\profiles\Chris\Desktop" Kyle [pc1]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top