Silent SaveAs when using the Excel win32com module

C

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.
 
C

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.

Googling around I found that a way around this is to just delete the
file before you save (if it exists)... any other solutions?
 
T

Tim Golden

Chris said:
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.

xl.DisplayAlerts = 0

where xl is the Application object.

TJG
 
M

MRAB

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,263
Messages
2,571,064
Members
48,769
Latest member
Clifft

Latest Threads

Top