Sub EnvironList()
' Warning: Never refer to an Environ value by its 'number', as you
' will get unpredictable results. Always include the Environ Name
' as in the GetWinUserName function.
Dim i As Integer
Dim stEnviron As String
For i = 1 To 50 ' 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