Thursday, October 18, 2018

#1 2017-12-27 11:53:41 am

Registered: 2016-01-17
Posts: 3

How do I trap a "file format not valid" alert from Excel?

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"
       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
end tell

Thanks very much!

Last edited by chan (2017-12-27 12:05:01 pm)



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)