How do I check error result occurring by filecopy function in VBA

  • Thread starter Thread starter Noa
  • Start date Start date
N

Noa

I writing in VBA for excell.
My program calls the filecopy function in a private function. If filecopy
fails, the program should analyze it and return with a failure value to the
main subrotine that calld the fuction (in a success execution of filecopy,
the function returns the workbook object of the new destination file). How
can I check the status of the execution?
How can I found out if the returnd workbook object has value or it's empty?
Thanks
 
Hi
I tend to do something like

Err.clear 'err is not destroyed when the sub ends
On Error Resume Next
'do the copy
If err.number<>0 then
'an error has occurred so do something
Else
'do something else
end if
On Error Goto 0

You could also capture the error number using Err.Number if you want
to do something with it.

regards
Paul
 
Back
Top