I´m trying to open some recovered files from HD crash, see if its openable, if not close Excel and delete the file.
Excel throws a “file format not valid” alert.
This alert keeps me from being able to do multiple files ( I have hundreds)
I have to stop for each file and press “ok” on the alert to continue.
I want to trap the error and close excel and erase file if not valid.
set theFile to choose file default location "/Users/xxxxx/Documents/DataRecoverydocs/Document/xlsx/"
tell application "Microsoft Excel"
activate
try
open theFile --Excel throws an alert "file format not valid"
--it´s a recovered file maybe corrupt
on error
display dialog " Excel could not open the file" --this is not working to trap Excel error!
end try
delay 2
quit
end tell
Thanks very much!