ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Login Information (https://www.excelbanter.com/excel-programming/290709-login-information.html)

Arvind P Rangan

Login Information
 
Hi,
How can we get the user login information into a excel sheet.

If anyone opens a excel sheet stored in a server whenever the user opens it,
a cell should display the user login name??

Can anyone help me on that.
Thanks

Arvind.




Bob Phillips[_6_]

Login Information
 
Arvind,

Here is a simple function that returns the network user id

Here is a function to do it

Public Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Public Function UserName() As String
Dim sName As String * 256
Dim cChars As Long
cChars = 256
If GetUserName(sName, cChars) Then
UserName = Left$(sName, cChars - 1)
End If
End Function

The cell could then use

=UserName()

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Arvind P Rangan" wrote in message
...
Hi,
How can we get the user login information into a excel sheet.

If anyone opens a excel sheet stored in a server whenever the user opens

it,
a cell should display the user login name??

Can anyone help me on that.
Thanks

Arvind.






Arvind Rangan

Login Information
 
Hi,
Thanks but how do i use the function and should i need to put the vb
code in the xls file.

WHERE TO put the code and how to access it.

Thanks
ARvind.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Bob Phillips[_6_]

Login Information
 
Arvind,

just put it in a standard code module, and you can use

=UserName()

in a worksheet cell.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Arvind Rangan" wrote in message
...
Hi,
Thanks but how do i use the function and should i need to put the vb
code in the xls file.

WHERE TO put the code and how to access it.

Thanks
ARvind.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





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

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