Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Feb 2001
    Location
    London UK, Gtr London, England
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting NT/2000 Environment Variables

    This is an ongoing problem I keep hitting and have yet to find an answer. What I would like to do is get NT/2000 Environment variables like %userprofile% or %machinename% or %logonServer% and use them in VB and VBA applications. Has anyone got any ideas on how to get these?

    Thanks

  2. #2
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting NT/2000 Environment Variables

    Richard,

    You could try:
    environ("userprofile") or environ("username").

    I'm on Win95 at the moment, so I don't have all values, so I don't know if this will help.

    For a list of all Environ identifiers and values, try:
    <pre>Dim i As Integer
    For i = 1 To 20
    Debug.Print i; Environ(i)
    Next
    </pre>

    If "i=20" shows a value, increase the upper limit (I don't know when to stop- the upper value, that is). That will show the environ names as well as values.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  3. #3
    Lounger
    Join Date
    Feb 2001
    Location
    London UK, Gtr London, England
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting NT/2000 Environment Variables

    Thanks! It works!
    I cant't belive that this has been bugging me for this long and the answer was that simple!!

    Much appreciated!

  4. #4
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting NT/2000 Environment Variables

    I was our site's Word VBA guru for a long time- and it's one of our LAN people who showed me that.

    Mind you, if there's the faintest possibility that your application will be hosted outside a WinNT environment, look for an API solution. There's posts in the forum to help you with that. Somewhere.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  5. #5
    Lounger
    Join Date
    Feb 2001
    Location
    London UK, Gtr London, England
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting NT/2000 Environment Variables

    Fortunatly i'm working on programs for a (Hopefully) standard desktop enviroment, but I do see your point. I was persuing the ADSI option which apparently would work in a NT4 Domain enviroment.

  6. #6
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting NT/2000 Environment Variables

    I've just received a PM that this helped somebody today.

    That's the power of a community like this. Something seven years old can still be of use. To somebody.

    And I'm not even in IT any more.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  7. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Getting NT/2000 Environment Variables

    >>"And I'm not even in IT any more"
    and you've lost your chef's hat too, oddly! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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