Tim,

   Here is one of the faster ways of getting the job done.

Function ap_GetComputerName()
'   
**********************************************************************
'   Obtain the computer name from the operating system.
    strDB_ComputerName = String$(255, 0)
          lngDB_Result = GetComputerName(strDB_ComputerName, 
lngDB_Length)
    ap_GetComputerName = Left(strDB_ComputerName, InStr(1, 
strDB_ComputerName, Chr(0)) - 1)
'   
**********************************************************************
***********************
End Function
Function ap_GetUserName()
'   
**********************************************************************
***********************
'   Obtain the user name from the operating system.
    strDB_UserName = String$(255, 0)
      lngDB_Result = GetUserName(strDB_UserName, lngDB_Length)
    ap_GetUserName = Left(strDB_UserName, lngDB_Length)
'   
**********************************************************************
***********************
End Function


--- In [email protected], "Heaton, Timothy H. \(USD\)" 
<[EMAIL PROTECTED]> wrote:
>
> I wrote a home-made Common Dialog Box for VBA, but I'm wondering if
> there's a way to grab the current Windows username in VBA. I want 
it for
> a shortcut to My Documents, as in:
> 
> ChDir "C:\Documents and Settings\" & UserName & "\My Documents"
> 
> Any ideas?
> 
> -Tim
>


Reply via email to