Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Common Environment Variables


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.
1) ALLUSERSPROFILE
2) APPDATA
3) chassis
4) CommonProgramFiles
5) CommonProgramFiles(x86)
6) CommonProgramW6432
7) COMPUTERNAME
8) ComSpec
9) FPS_BROWSER_APP_PROFILE_STRING
10) FPS_BROWSER_USER_PROFILE_STRING
11) HOMEDRIVE
12) HOMEPATH
13) LOCALAPPDATA
14) LOGONSERVER
15) model
16) NUMBER_OF_PROCESSORS
17) OneDrive
18) OS
19) Path
20) PATHEXT
21) PLMVIS_82_LIBPATH
22) PROCESSOR_ARCHITECTURE
23) PROCESSOR_ARCHITEW6432
24) PROCESSOR_IDENTIFIER
25) PROCESSOR_LEVEL
26) PROCESSOR_REVISION
27) ProgramData
28) ProgramFiles
29) ProgramFiles(x86)
30) ProgramW6432
31) PSModulePath
32) PUBLIC
33) serial
34) SESSIONNAME
35) SNC_LIB
36) snow_agent
37) SystemDrive
38) SystemRoot
39) TEMP
40) TMP
41) type
42) UATDATA
43) USERDNSDOMAIN
44) USERDOMAIN
45) USERDOMAIN_ROAMINGPROFILE
46) USERNAME
47) USERPROFILE
48) windir



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



Subscribe

Enter your e-mail below and get notified on the latest blog posts.




Tags

VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts


Follow Us