ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I check error result occurring by filecopy function in VBA (https://www.excelbanter.com/excel-programming/442442-how-do-i-check-error-result-occurring-filecopy-function-vba.html)

Noa

How do I check error result occurring by filecopy function in VBA
 
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


Paul Robinson

How do I check error result occurring by filecopy function in VBA
 
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
On May 11, 9:23*am, Noa wrote:
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




All times are GMT +1. The time now is 12:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com