Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Environ("username") in 2007

debug.Print Environ("username") does work on 2003 but not on 2007?

I have read other posting with a similar question and it is written ther
"problem is solved by changing the environmental variables" - how do you do
that or any other suggestion?
Many thanks,
Dan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Environ("username") in 2007

Works on my system.

--

HTH

Bob

"Dan" wrote in message
...
debug.Print Environ("username") does work on 2003 but not on 2007?

I have read other posting with a similar question and it is written ther
"problem is solved by changing the environmental variables" - how do you
do
that or any other suggestion?
Many thanks,
Dan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Environ("username") in 2007

My guess is that it's more related to the version of windows (not excel) that
you're running.

You may want to share that to see if others running the same configuration will
comment.

Dan wrote:

debug.Print Environ("username") does work on 2003 but not on 2007?

I have read other posting with a similar question and it is written ther
"problem is solved by changing the environmental variables" - how do you do
that or any other suggestion?
Many thanks,
Dan


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Environ("username") in 2007

The problem is on XP, but I tried on another XP I have and working fine on
it, so maybe my installation is wrong.


"Dave Peterson" wrote:

My guess is that it's more related to the version of windows (not excel) that
you're running.

You may want to share that to see if others running the same configuration will
comment.

Dan wrote:

debug.Print Environ("username") does work on 2003 but not on 2007?

I have read other posting with a similar question and it is written ther
"problem is solved by changing the environmental variables" - how do you do
that or any other suggestion?
Many thanks,
Dan


--

Dave Peterson
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Environ("username") in 2007

You could verify that the environment variable exists.

Windows start button|Run
type:
cmd
and hit enter.

Then type:
Set
and hit enter

Scroll up/down looking for USERNAME.

It works fine for me with WinXP Pro and xl2007.

========
But there are other ways to get the username, too:

Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX < 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function

Sub testme()
MsgBox fOSUserName 'to test to see if it worked.
End Sub



Dan wrote:

The problem is on XP, but I tried on another XP I have and working fine on
it, so maybe my installation is wrong.

"Dave Peterson" wrote:

My guess is that it's more related to the version of windows (not excel) that
you're running.

You may want to share that to see if others running the same configuration will
comment.

Dan wrote:

debug.Print Environ("username") does work on 2003 but not on 2007?

I have read other posting with a similar question and it is written ther
"problem is solved by changing the environmental variables" - how do you do
that or any other suggestion?
Many thanks,
Dan


--

Dave Peterson
.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Environ("Username") with Windows7 64bit Jamen Lone Excel Programming 5 February 13th 10 11:48 PM
Converting Environ("username") from 2003 to 2007 Chilidog Excel Programming 5 September 17th 09 05:47 PM
Environ("USERNAME") Heera Excel Programming 5 August 12th 09 01:54 PM
environ username vs. application username jatman Excel Programming 4 May 28th 09 08:40 AM
Environ("username") riso Excel Programming 11 March 9th 07 10:43 AM


All times are GMT +1. The time now is 02:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"