Automatically overwriting files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greetings,

I have the following VBA code which saves a text file to a certain folder.
However, if that file already exists, it displays a dialog box asking me if I
want to overwrite the existing file. I always want to answer "Yes" to this
dialog. However, I won't always know if a file by that same name already
exists before the code is run. That means that the dialog will not always
appear. I guess I could use Sendkeys, but that would only work if an
existing file by that same name would always be in that folder. Any idea as
to how to get around this?

ActiveWorkbook.SaveAs Filename:="C:\filename.txt", FileFormat:=xlText, _
CreateBackup:=False
 
Hi Sherwood

Before the save
Application.DisplayAlerts = False

amd after the save
Application.DisplayAlerts = True
 
Thanks, Ron. I appreciate it.
--
Sherwood


Ron de Bruin said:
Hi Sherwood

Before the save
Application.DisplayAlerts = False

amd after the save
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

Back
Top