ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Environ function. (https://www.excelbanter.com/excel-programming/327433-re-environ-function.html)

Tom Ogilvy

Environ function.
 
Environ is a function, so it has not properties and methods

You can do this to see what is available

Sub AA()
i = 1
Do While Environ(i) < ""
Debug.Print Environ(i)
i = i + 1
Loop
End Sub

this produces output like

TEMP=C:\DOCUME~1\OgilvyTW\LOCALS~1\Temp
TMP=C:\DOCUME~1\OgilvyTW\LOCALS~1\Temp
USERDOMAIN=XXXX
USERNAME=OgilvyTW
USERPROFILE=C:\Documents and Settings\OgilvyTW

so now I see I can get the username by doing

msgbox environ("Username")

--
Regards,
Tom Ogilvy




"DaveO" wrote in message
...
Looking for some help on Environ.

Need to know more about the methods and properties it has so I can see

what
I can do.

Ultimately (at this early stage) trying to get the logged on username of

the
current user for validation purposes.

Any ideas??




Bob Phillips[_6_]

Environ function.
 
You can also set or add to environment variables using

Private Declare Function SetEnvironmentVariable Lib "kernel32" _
Alias "SetEnvironmentVariableA" _
(ByVal lpName As String, _
ByVal lpValue As String) As Long

SetEnvironmentVariable "Rob", "Nuzie2!"

Unfortunately, Environ gets the values when Excelk started, so it won't know
of these values.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"DaveO" wrote in message
...
Thanks Tom, got the idea now mate, thanks.


"Tom Ogilvy" wrote:

Environ is a function, so it has not properties and methods

You can do this to see what is available

Sub AA()
i = 1
Do While Environ(i) < ""
Debug.Print Environ(i)
i = i + 1
Loop
End Sub

this produces output like

TEMP=C:\DOCUME~1\OgilvyTW\LOCALS~1\Temp
TMP=C:\DOCUME~1\OgilvyTW\LOCALS~1\Temp
USERDOMAIN=XXXX
USERNAME=OgilvyTW
USERPROFILE=C:\Documents and Settings\OgilvyTW

so now I see I can get the username by doing

msgbox environ("Username")

--
Regards,
Tom Ogilvy




"DaveO" wrote in message
...
Looking for some help on Environ.

Need to know more about the methods and properties it has so I can see

what
I can do.

Ultimately (at this early stage) trying to get the logged on username

of
the
current user for validation purposes.

Any ideas??








All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com