Have a list of Environ variables?

S

Scott Warren

I'm looking to see if any has a list, or know where I can
get a list of variables that I can use the Environ()
function on. Specifially I'm trying to log a users Domain
when they open the file. I've been able to get the
following variable so far:


User = Environ("USERNAME")
Machine = Environ("COMPUTERName")


Thanks,

-Scott
 
J

jaf

Hi Scott,
Sub Environ_Check()
Dim r As Long
Dim P As Long
r = 1
Do
Cells(r, 1) = r
Cells(r, 2) = Environ$(r)

P = InStr(1, Cells(r, 2), "=")
Cells(r, 3) = Left$(Cells(r, 2), P - 1)

' 'or the following with Excel 2000
' Cells(r, 3) = Split(Cells(r, 2), "=")(0)
r = r + 1
Loop Until Len(Environ$(r)) = 0
Columns("A:B").AutoFit
[A1].Select
End Sub
 
T

Tom Ogilvy

I don't believe there is a standard set across all windows OS, but you can
see yours with

Sub ListEnviron()
On Error Resume Next
rw = 1
For i = 1 To 100
If Environ(i) <> "" Then
Cells(rw, 1) = Environ(i)
rw = rw + 1
End If
Next
Cells(rw + 1, 1) = rw
End Sub

I had

USERDOMAIN
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top