In many macros you need access active session environment settings like username, computer name, etc. The easiest way to do this is using Windows environment variables. To see what environment variables are available open a Command Prompt window and enter the SET command. Some of the more common examples are shown in the code sample below:
Sub MyMacro()
Dim strUsername As String
Dim strComputername As String
Dim strTempFolder As String
Dim strUserProfile As String
strUsername = Environ$(“USERNAME”)
strComputername = Environ$(“COMPUTERNAME”)
strTempFolder = Environ$(“TEMP”)
strUserProfile = Environ$(“USERPROFILE”)
End Sub