INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site
(Download This Button Today!)
"...Thanks for a great forum. My problem was answered just by scrolling through previously solved problems.
Where in the world do Tek-Tips members come from?
Office / VBA General
List environment variables
Posted: 13 Oct 03
This FAQ is simply some code to show all the current environment variables for the current excel session. Environment variables can be used to test for users, homedrives, no. of processors and domains amoungst other things. It works on windows only (sorry mac users) and I use it most often to obtain the network userid of the current user. This is especially useful where you have different types of access depending on who the user is.
This code will show all the environment variables:
Dim EnvString As String
Indx = 1
EnvString = Environ(Indx)
Cells(Indx, 1) = EnvString
Indx = Indx + 1
Loop Until EnvString = ""
The one I use most is
so you can use
dim myUser as string
myUser = environ("username")
to return the current user's network id
Back to VBA Visual Basic for Applications (Microsoft) FAQ Index
Back to VBA Visual Basic for Applications (Microsoft) Forum
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close