On Sun, 01 Jan 2006 12:53:48 -0600, Lauren Wilson <no****@none.com> wrote:
Well Wayne, I have made very good use of your excellent FTP class
module. There is only one remaining problem: Despite the fact that
you defined FTP error codes in FTPClient, I cannot seem to get the
errors to trigger when they should (for example, "No Internet
connection", or "Invalid login", etc.) Do I need to Raise these
error's myself? If so, how will I know if they have happened (from
VBA code that is)?
To test the most basic error possibilities, I deliberately used an
invalid login. No error was triggered.
What am I missing?
Thanks for your help. Happy New Year!
--LW
Check that the RaiseError lines have not been remmed out and replaced by setting a public variable as in the following
extract. I took the code from a project I did 3 or 4 years ago and can't rememeber why I did it this way, but there was
a reason :)
Un rem the line -
If m_hCon = 0 Then RaiseError errOpenCon
And rem out the If statement that follows this line.
Public Sub OpenServer(Optional pServerName, Optional pUserName, Optional pPassword)
'Establish connection to server
'If FTP session not initiated
If m_hFTP = 0 Then RaiseError errNotOpen
'
'Handle optional parameters
If Not IsMissing(pServerName) Then m_ServerName = pServerName
If Not IsMissing(pUserName) Then m_UserName = pUserName
If Not IsMissing(pPassword) Then m_Password = pPassword
'
'Handle empty properties
If Len(m_ServerName) = 0 Then RaiseError errNoServer
'
'The following are translated to:
' UserName: Anonymous
' Password: default email address
'by the API, if nulls passed
If Len(m_UserName) = 0 Then m_UserName = vbNullString
If Len(m_Password) = 0 Then m_Password = vbNullString
'
m_hCon = InternetConnect(m_hFTP, m_ServerName, INTERNET_INVALID_PORT_NUMBER, _
m_UserName, m_Password, INTERNET_SERVICE_FTP, _
INTERNET_FLAG_PASSIVE, 0)
'If m_hCon = 0 Then RaiseError errOpenCon <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
If m_hCon = 0 Then
booIsConnected = False
Exit Sub
Else
booIsConnected = True
End If
End Sub
Wayne Gillespie
Gosford NSW Australia