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

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
 
P

Paul Robinson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top