---- Mark Hammond <[EMAIL PROTECTED]> schreef:
> > > Normally I can just press "close" in the excel error box, and
> > continue
> > > to work on the file. But how do I handle this in py-win32?
> > 
> > So what happens when you try to open it normally?
> 
> Oops - sorry - I see you already gave the exception you get trying to open
> the file.  I'm afraid I don't know the answer though.
> 

In answer to my own question, the following code seems to work:

xlApp = Dispatch("Excel.Application")
wb1=xlApp.Workbooks.Open(inputfile,ReadOnly=1,CorruptLoad=1)
xlApp.SendKeys("{Enter}",Wait=1)
xlApp.DisplayAlerts = 0
xlApp.Quit()
del xlApp

The trick was to find the right CorruptLoad statement and corresponding number 
for "xlRepairFile".

The DisplayAlerts is needed to prevent Excel from asking if it should save a 
file that was opened as ReadOnly in the first place... hmmmm.

Best regards,

Patrick Asselman
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to