I have code that among other things, copies an excel file from our server, renames it and places it into another file. Occasionally remote users get errors at this "FileCopy Source" line. My assumption is that there was a data transfer issue (or other issue) that caused the file to not be copied. So, I have been attempting to write error handling to 1. attempt the "FileCopy Source" one more time, 2. if that causes another error, notify the user of the error and to remove some information that was entered into a worksheet via previous code. On the "FileCopy Sourse" line, I have purposefully changed the file name to one that does not exist to force an error. I have been messing with the error handling all day and can not get it to work. I simply get the File Not Found error. In my latest attempt to simplify, I have removed one error handler and just hoping to get "Punt" to work for starters.
Any help would be greatly appreciated.
Any help would be greatly appreciated.
Code:
'Add SCCO Workbook
NewSCCO = SCLogPath & "\" & FixSubcontractor & Number & ".xls"
'ATTEMPT TO CORRECT ERRORS THOUGHT TO BE CAUSED BY DATA CONNECTION
On Error GoTo Punt
FileCopy Source:="H:\WSBCC Forms\SCCO Template\SCCOx.xls", Destination:=NewSCCO
On Error GoTo 0
'
'
'
'many lines of working code
'
'
'
Exit Sub
'SCcoError:
' 'On Error GoTo Punt
' FileCopy Source:="H:\WSBCC Forms\SCCO Template\SCCO.xls", Destination:=NewSCCO
' On Error GoTo 0
' Resume Next
Punt:
Worksheets("SC Log").Unprotect "2132"
Range(ItemRow).Clear
Worksheets("SC Log").Protect "2132"
ActiveWorkbook.Save
MsgBox "There was an error that prevented the creation of the Subcontract CO file. Please try again. If the problem persists, contact Admin"
Resume Next
End Sub