Mike Lewis
Programmer
I am using Automation to add passwords to a batch of Excel files. I thought this would be straightforward: just open each workbook in turn, then save it with the password:
The problem is the SaveAs method sees that the file already exists, and so prompts for permission to overwrite it. I want to run this code unattendend, so I need to avoid these prompts.
I can't set DisplayAlerts to .F. becuase that would cause Excel to execute the default action, which is not to save the file.
Anyone got any bright ideas about how to avoid this prompt?
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro tips, advice, training, consultancy
Custom software for your business
Code:
SELECT Books && table containing my filenames
SCAN
loBook = ;
loExcel.Workbooks.Open(Books.Filename)
loBook.SaveAs(Books.Filename, , lcPassword)
loBook.Close(.F.)
ENDSCAN
The problem is the SaveAs method sees that the file already exists, and so prompts for permission to overwrite it. I want to run this code unattendend, so I need to avoid these prompts.
I can't set DisplayAlerts to .F. becuase that would cause Excel to execute the default action, which is not to save the file.
Anyone got any bright ideas about how to avoid this prompt?
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro tips, advice, training, consultancy
Custom software for your business