Thread: Username
View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Oldjay Oldjay is offline
external usenet poster
 
Posts: 337
Default Username

Thanks for all the help. I went ahead with the Application .username even
thou once in a while a user will use another computer and get the wrong name.

"Peter T" wrote:

I did try earlier to suggest the OP check for any missing references and how
to overcome (even how to get Environ to work with a missing ref). The OP's
stated error message was indeed indicative of a missing ref.

However, Environ("Username") does not work in all systems, it's flaky. It
doesn't work in mine, doesn't fail but merely returns an empty string.

The API is more reliable, subject not declaring it as Public in anything but
a normal module (which is what "Declare" defaults to when not preceded with
"Private").

Regards,
Peter T

"Tom Hutchins" wrote in message
...
Clearly, there is no problem with the code. It must be an environmental
(system) problem, Excel has become corrupted, or there is a conflict with
another program.

First, I would double-check the references in the VBE on the computers

that
won't run the Environ("username") statement. Maybe, for example, your
workbook was saved with a reference to the Excel 11.0 Object Library but
those machines only have the Excel 10.0 Object Library.

Second, I would check what add-ins, if any, are enabled on those machines.
Some add-ins (like Hyperion's SmartView) can alter or disable normal Excel
functions. Disable any add-ins not found on the machines that work, and

see
if Environ("username") works then.

Hutch

"Oldjay" wrote:

I can open a new workbook paste the code and get Lan ID
When I insert a new module in the existing workbook and paste the code I

get
the same error. It's got to be something in this machine as the program

works
with Environ("username") on other machines. This a 3.5M estimating

program
with many menus and modules and more than 75 Subs.

Is there any other thing that I can look for?

"Tom Hutchins" wrote:

For me,

?Environ(49) displays nothing
?Environ("username") displays my LAN ID

Hutch

"timmg" wrote:

What does

?Environ(49)

or

?Environ("username")

display when entered directly in the immediate window? (ctrl + G)

tim