'put this in a module
Option Explicit
Option Compare Database
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nsize As Long) As Long
Public str
Sub Get_User_Name()
Dim lpBuff As String * 25
Dim ret As Long, strUserName As String
ret = GetUserName(lpBuff, 25)
strUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
Debug.Print Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
str = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Sub
'then you put this on your form
Dim strCopyString As String
Get_User_Name
strCopyString = ""
strCopyString = "C:\Documents and Settings\"
strCopyString = strCopyString & str 'str comes from the module
strCopyString = strCopyString & "\Desktop\file.txt"
This is what I use to put a file on the users desktop. Works like a charm.
Sal
|