Silent SaveAs when using the Excel win32com module

MRAB google at mrabarnett.plus.com
Mon Sep 10 18:41:07 EDT 2007


On Sep 10, 5:24 pm, "Hamilton, William " <wham... at entergy.com> wrote:
> > From: Chris
>
> > I'm trying to create an excel file which will act as a log, however I
> > want to overwrite the file if it exists.
>
> > Looking at the SaveAs method I can't find anything that would allow
> > it. I don't want the prompt to appear to ask whether to replace the
> > file or not. I just want to replace it without thinking.
>
> > Thanks in advance.
>
> Check if the file exists and delete it before saving the new one.
>
It's more Pythonic to delete the file and catch the exception if it
doesn't actually exist.




More information about the Python-list mailing list