Avoiding Overwrite Confirmation

J

Jerry Camel

I've got a script that collects information and then formats it in an Excel
sheet. I wasn tthe script to save the sheet with a particular filename,
even if the old file (say, from last week's run) is still there. Is there a
way to tell Excel it's okay ot overwrite the file when I call the SaveAs
method? I don't want to require user interaction.

I'm guessing I have to look for the file first and delete it
programmatically, but it seemed like such a simple option that I wanted to
ask first, to make sure I'm not missing anything. Thanks.

Jerry
 
J

J.E. McGimpsey

One way:

Wrap your code like this:

Application.DisplayAlerts = False
ThisWorkbook.SaveAs fName
Application.DisplayAlerts = True
 
J

Jerry Camel

That was simple enough... Thanks.

Jerry

J.E. McGimpsey said:
One way:

Wrap your code like this:

Application.DisplayAlerts = False
ThisWorkbook.SaveAs fName
Application.DisplayAlerts = True
 

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

Top