Provided is a list of common environment variables. The following will be useful when you develop dynamic VBA Applications depends on user/system and other environments.
Sub get_username()
'Username
MsgBox Environ("Username")
End Sub
Sub get_computername()
'Computer Name
MsgBox Environ("ComputerName")
End Sub
Sub Print_Environ_Functions()
Dim i As Integer
Dim stEnviron As String
For i = 1 To 100
' get the environment variable
stEnviron = Environ(i)
' see if there is a variable set
If Len(stEnviron) > 0 Then
Debug.Print i, Environ(i)
Else
Exit For
End If
Next
End Sub