+ Reply to Thread
Results 1 to 4 of 4

Access system-environment variables

  1. #1
    Perry
    Guest

    Access system-environment variables

    Is there an (easy) way to access those variables displayed using the
    dos "set" command from an Excel Macro

    Specifically want to target username, userdomain, homedrive.

    Thanks


  2. #2
    Ardus Petus
    Guest

    Re: Access system-environment variables

    dim s as String
    s = environ("username")


    HTH
    --
    AP

    "Perry" <[email protected]> a écrit dans le message de
    news:[email protected]...
    > Is there an (easy) way to access those variables displayed using the
    > dos "set" command from an Excel Macro
    >
    > Specifically want to target username, userdomain, homedrive.
    >
    > Thanks
    >




  3. #3
    Norman Jones
    Guest

    Re: Access system-environment variables

    Hi Perry,

    > Is there an (easy) way to access those variables displayed using the
    > dos "set" command from an Excel Macro
    >
    > Specifically want to target username, userdomain, homedrive.



    Try:

    '=============>>
    Public Sub ListEnviron()
    Dim SH As Worksheet
    Dim i As Long
    Dim iPos As Long

    Set SH = ActiveWorkbook.Sheets.Add

    With SH
    .Name = "Environ List"
    i = 1
    While Environ(i) <> ""
    iPos = InStr(Environ(i), "")
    .Cells(i, "A").Value = i
    .Cells(i, "B").Value = "'" & Mid(Environ(i), iPos)
    i = i + 1
    Wend
    .Columns("B:C").AutoFit
    End With

    End Sub
    '<<=============

    If you are not familiar with macros, you may wish to visit David McRitchie's
    'Getting Started With Macros And User Defined Functions' at:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm


    ---
    Regards,
    Norman



  4. #4
    Perry
    Guest

    Re: Access system-environment variables

    Perfect. Thanks Norman & AP


+ 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