There's a lot of information available from the ENVIRON function -- use
as ENVIRON(<argument>). The following code gives you all the possible
values you can get:
Sub testIt()
Dim Indx As Long, EnvString As String
Indx = 1
Do
EnvString = Environ(Indx)
ActiveCell.Offset(Indx - 1, 0) = Environ(Indx)
Indx = Indx + 1
Loop Until EnvString = ""
End Sub
The code above puts the results in a column starting with the
activecell. Make sure the column is empty or the code will overwrite
whatever data are present in the column!
Once you run the above code you can decide what exactly you really
want:
ALLUSERSPROFILE
APPDATA
CommonProgramFiles
COMPUTERNAME
ComSpec
HOMEDRIVE
HOMEPATH
LOGONSERVER
NUMBER_OF_PROCESSORS
OS
Path
PATHEXT
PROCESSOR_ARCHITECTURE
PROCESSOR_IDENTIFIER
PROCESSOR_LEVEL
PROCESSOR_REVISION
ProgramFiles
SESSIONNAME
SystemDrive
SystemRoot
TEMP
TMP
USERDOMAIN
USERNAME
USERPROFILE
windir
--
Regards,
Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions