Hi,
This gets the username:
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''
' Copyright ©1996-2001 VBnet, Randy Birch, All Rights
Reserved.
' Some pages may also contain other copyrights by the
author.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''
' You are free to use this code within your own
applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written
consent.
' This includes both posting free demo projects made from
this
' code as well as reproducing the code in text or html
format.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''
Private Const MAX_USERNAME As Long = 256
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long
Function rgbGetUserName() As String
'return the name of the user
Dim tmp As String
tmp = Space$(MAX_USERNAME)
If GetUserName(tmp, Len(tmp)) Then
rgbGetUserName = TrimNull(tmp)
End If
End Function
Private Function TrimNull(item As String)
Dim pos As Integer
pos = InStr(item, Chr$(0))
If pos Then
TrimNull = Left$(item, pos - 1)
Else: TrimNull = item
End If
End Function
Don't know a way to get the password though.
Regards,
Jan Karel Pieterse
Excel TA/MVP