Option Explicit ' forces declaration of variables
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public orig_path As String
Public username As String
Private Sub Desktop_Cmd_Click()
On Error GoTo err_form_load
orig_path = "C:\Documents and Settings\" & username & "\Desktop"
Dir1.Path = orig_path
Exit Sub
err_form_load: '*********** error handler ****************
MsgBox Err.Number & Err.Description
Resume
End Sub
You don't say which of these routines it is erroring from. It would help if the MsgBox error message included subroutine name as well as error message.
However if we take subroutine above then I am not surprised it goes round and round without stopping for following reason.
orig_path = "C:\Documents and Settings\" & username & "\Desktop"
It looks to me as if you are trying to point path to the users Destop folder. However username does not appear to be defined.
Therefore the program errors.
Then prints out the error message.
Your program then says Resume which I believe will take it to
orig_path = "C:\Documents and Settings\" & username & "\Desktop"
Which then errors..........
Hope this helps you sort it.
Denis