Can anyone see a problem with the following code?
Where sFolderSource = "C:\Familygrams_Received\SHIPNAME\Signal" which exists and
sFolderDestination = CurrentProject.path & "\SHIPNAME\Signal\Archive\" which does not yet exist.
The error handler kicks in at fsCopyFolder line with Error 76
Code:
Function MoveFolder(sFolderSource As String, sFolderDestination As String, _
bOverWriteFiles As Boolean) As Boolean
On Error GoTo Error_Handler
Dim fs As Object
MoveFolder = False
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFolder sFolderSource, sFolderDestination, bOverWriteFiles
fs.DeleteFolder sFolderSource, True
MoveFolder = True
Error_Handler_Exit:
On Error Resume Next
Set fs = Nothing
Exit Function
Error_Handler:
If Err.Number = 76 Then
MsgBox "The 'Source Folder' could not be found to make a copy of.", _
vbCritical, "Unable to Find the Specified Folder"
Else
MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: MoveFolder" & vbCrLf & _
"Error Description: " & Err.Description, _
vbCritical, "An Error has Occured!"
End If
Resume Error_Handler_Exit
End Function
Where sFolderSource = "C:\Familygrams_Received\SHIPNAME\Signal" which exists and
sFolderDestination = CurrentProject.path & "\SHIPNAME\Signal\Archive\" which does not yet exist.
The error handler kicks in at fsCopyFolder line with Error 76