+ Reply to Thread
Results 1 to 4 of 4

Environment Variable Names

  1. #1
    Chaplain Doug
    Guest

    Environment Variable Names

    Excel 2003. I am using the Environ function to return the "UserName"
    environment variable (i.e., Environ("UserName")). Where would I find a
    listing of the other environment variables avaiable for use with the Environ
    function? Or put another way, what other environment variables can I use
    with the Environ function? Thanks and God bless.
    Dr. Doug Pruiett
    Good News Jail & Prison Ministry
    www.goodnewsjail.org

  2. #2
    Chip Pearson
    Guest

    Re: Environment Variable Names

    Run the following code. It will but the name of the environ
    variable in column A and the value in column B.

    Sub ListEnvioron()
    Dim Rng As Range
    Dim Ndx As Long
    Dim S As String
    Dim Pos As Long

    Ndx = 1
    On Error Resume Next
    Set Rng = Range("A1")
    Do While True
    S = Environ(Ndx)
    If Err.Number <> 0 Then
    Exit Do
    End If
    Pos = InStr(1, S, "=")
    Rng.Value = Left(S, Pos - 1)
    Rng(1, 2).Value = Mid(S, Pos + 1)
    Ndx = Ndx + 1
    Set Rng = Rng(2, 1)
    Loop
    End Sub


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "Chaplain Doug" <[email protected]> wrote in
    message
    news:[email protected]...
    > Excel 2003. I am using the Environ function to return the
    > "UserName"
    > environment variable (i.e., Environ("UserName")). Where would
    > I find a
    > listing of the other environment variables avaiable for use
    > with the Environ
    > function? Or put another way, what other environment variables
    > can I use
    > with the Environ function? Thanks and God bless.
    > Dr. Doug Pruiett
    > Good News Jail & Prison Ministry
    > www.goodnewsjail.org




  3. #3
    AA2e72E
    Guest

    RE: Environment Variable Names

    Try:

    Sub xx()
    Set ws = CreateObject("WScript.Shell").Environment
    For Each Item In ws
    Debug.Print Item
    Next
    Set ws = Nothing
    End Sub


    Debug.Print Item will list each environment variable in the Immediate
    Window; you need to ensure it is visible OR change the code to return the
    result in a string.
    The immediate Window should have something like this

    .....
    PROCESSOR_REVISION=0806
    TEMP=%SystemRoot%\TEMP
    TMP=%SystemRoot%\TEMP
    WIN32DMIPATH=c:\dmi\win32
    windir=%SystemRoot%



    "Chaplain Doug" wrote:

    > Excel 2003. I am using the Environ function to return the "UserName"
    > environment variable (i.e., Environ("UserName")). Where would I find a
    > listing of the other environment variables avaiable for use with the Environ
    > function? Or put another way, what other environment variables can I use
    > with the Environ function? Thanks and God bless.
    > Dr. Doug Pruiett
    > Good News Jail & Prison Ministry
    > www.goodnewsjail.org


  4. #4
    Chaplain Doug
    Guest

    RE: Environment Variable Names

    Thanks guys.
    --
    Dr. Doug Pruiett
    Good News Jail & Prison Ministry
    www.goodnewsjail.org


    "Chaplain Doug" wrote:

    > Excel 2003. I am using the Environ function to return the "UserName"
    > environment variable (i.e., Environ("UserName")). Where would I find a
    > listing of the other environment variables avaiable for use with the Environ
    > function? Or put another way, what other environment variables can I use
    > with the Environ function? Thanks and God bless.
    > Dr. Doug Pruiett
    > Good News Jail & Prison Ministry
    > www.goodnewsjail.org


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1