ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserName Function: Not Working (https://www.excelbanter.com/excel-programming/401440-username-function-not-working.html)

ryguy7272

UserName Function: Not Working
 
I used this little trick in the office for a few recent projects:
http://www.j-walk.com/ss/excel/tips/tip94.htm

It works perfectly fine on the machines in the office, with the exception of
one machine. As far as I can tell, we have all the MS critical updates for
this machine. I found the advapi32.dll on the problem-machine too. I can't
figure out what it is. Any thoughts or suggestions?

Regards,
Ryan--


--
RyGuy

sebastienm

UserName Function: Not Working
 
Hi,
What do you mean by it doesn't work:
- returns the wrong username
- an error pops up
- ...
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"ryguy7272" wrote:

I used this little trick in the office for a few recent projects:
http://www.j-walk.com/ss/excel/tips/tip94.htm

It works perfectly fine on the machines in the office, with the exception of
one machine. As far as I can tell, we have all the MS critical updates for
this machine. I found the advapi32.dll on the problem-machine too. I can't
figure out what it is. Any thoughts or suggestions?

Regards,
Ryan--


--
RyGuy


ryguy7272

UserName Function: Not Working
 
Oh yes, sorry, an error message pops up.
Any thoughts on what may cause this?

--
RyGuy


"sebastienm" wrote:

Hi,
What do you mean by it doesn't work:
- returns the wrong username
- an error pops up
- ...
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"ryguy7272" wrote:

I used this little trick in the office for a few recent projects:
http://www.j-walk.com/ss/excel/tips/tip94.htm

It works perfectly fine on the machines in the office, with the exception of
one machine. As far as I can tell, we have all the MS critical updates for
this machine. I found the advapi32.dll on the problem-machine too. I can't
figure out what it is. Any thoughts or suggestions?

Regards,
Ryan--


--
RyGuy


Niek Otten

UserName Function: Not Working
 
What error message?
We're not clairvoyant, you see........

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"ryguy7272" wrote in message ...
| Oh yes, sorry, an error message pops up.
| Any thoughts on what may cause this?
|
| --
| RyGuy
|
|
| "sebastienm" wrote:
|
| Hi,
| What do you mean by it doesn't work:
| - returns the wrong username
| - an error pops up
| - ...
| --
| Regards,
| Sébastien
| <http://www.ondemandanalysis.com
|
|
| "ryguy7272" wrote:
|
| I used this little trick in the office for a few recent projects:
| http://www.j-walk.com/ss/excel/tips/tip94.htm
|
| It works perfectly fine on the machines in the office, with the exception of
| one machine. As far as I can tell, we have all the MS critical updates for
| this machine. I found the advapi32.dll on the problem-machine too. I can't
| figure out what it is. Any thoughts or suggestions?
|
| Regards,
| Ryan--
|
|
| --
| RyGuy



sebastienm

UserName Function: Not Working
 
What error message?

In the meantime, you may want to try this implementation, found on vbcode.com:

Public Function GetLoggedInUserName() as string
Dim cn As String
dim Name as String
Dim ls As Long
Dim res As Long

cn = String(1024, 0)
ls = 1024
res = GetUserName(cn, ls)

If res < 0 Then
name = Mid(cn, 1, InStr(cn, Chr(0)) - 1)
Else
name = ""
End If

GetLoggedInUserName = Name
End function
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"ryguy7272" wrote:

Oh yes, sorry, an error message pops up.
Any thoughts on what may cause this?

--
RyGuy


"sebastienm" wrote:

Hi,
What do you mean by it doesn't work:
- returns the wrong username
- an error pops up
- ...
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"ryguy7272" wrote:

I used this little trick in the office for a few recent projects:
http://www.j-walk.com/ss/excel/tips/tip94.htm

It works perfectly fine on the machines in the office, with the exception of
one machine. As far as I can tell, we have all the MS critical updates for
this machine. I found the advapi32.dll on the problem-machine too. I can't
figure out what it is. Any thoughts or suggestions?

Regards,
Ryan--


--
RyGuy


ryguy7272

UserName Function: Not Working
 
Whoops, sorry again.; very tired now. I think the error says:
#NAME

I'm not at that workstation to test it now.

I was thinking it may be a corrupt dll file. Is that possible? Could the
'advapi32.dll' gotten corrupted and caused JWalk's function to create this
error? Doesn't XP just rebuild these types of corrupted dll files? I've
been using VBA for a couple of years and I haven't run into this before. I'm
baffled. Any insight would be appreciated.





--
RyGuy


"Niek Otten" wrote:

What error message?
We're not clairvoyant, you see........

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"ryguy7272" wrote in message ...
| Oh yes, sorry, an error message pops up.
| Any thoughts on what may cause this?
|
| --
| RyGuy
|
|
| "sebastienm" wrote:
|
| Hi,
| What do you mean by it doesn't work:
| - returns the wrong username
| - an error pops up
| - ...
| --
| Regards,
| Sébastien
| <http://www.ondemandanalysis.com
|
|
| "ryguy7272" wrote:
|
| I used this little trick in the office for a few recent projects:
| http://www.j-walk.com/ss/excel/tips/tip94.htm
|
| It works perfectly fine on the machines in the office, with the exception of
| one machine. As far as I can tell, we have all the MS critical updates for
| this machine. I found the advapi32.dll on the problem-machine too. I can't
| figure out what it is. Any thoughts or suggestions?
|
| Regards,
| Ryan--
|
|
| --
| RyGuy




ryguy7272

UserName Function: Not Working
 
Thanks for taking a crack at it everyone. Still unsure what the problem is,
but I am going to use a different technique altogether.


Regards,
Ryan--


--
RyGuy


"sebastienm" wrote:

What error message?

In the meantime, you may want to try this implementation, found on vbcode.com:

Public Function GetLoggedInUserName() as string
Dim cn As String
dim Name as String
Dim ls As Long
Dim res As Long

cn = String(1024, 0)
ls = 1024
res = GetUserName(cn, ls)

If res < 0 Then
name = Mid(cn, 1, InStr(cn, Chr(0)) - 1)
Else
name = ""
End If

GetLoggedInUserName = Name
End function
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"ryguy7272" wrote:

Oh yes, sorry, an error message pops up.
Any thoughts on what may cause this?

--
RyGuy


"sebastienm" wrote:

Hi,
What do you mean by it doesn't work:
- returns the wrong username
- an error pops up
- ...
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"ryguy7272" wrote:

I used this little trick in the office for a few recent projects:
http://www.j-walk.com/ss/excel/tips/tip94.htm

It works perfectly fine on the machines in the office, with the exception of
one machine. As far as I can tell, we have all the MS critical updates for
this machine. I found the advapi32.dll on the problem-machine too. I can't
figure out what it is. Any thoughts or suggestions?

Regards,
Ryan--


--
RyGuy



All times are GMT +1. The time now is 10:37 AM.

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