Say 'YES' to overwrite file

  • Thread starter Thread starter Mike G.
  • Start date Start date
M

Mike G.

Dear Guru's and Experts:

I'm sure this is a simple one for you.

I want my script to automatically reply "YES" when
prompted if I wish to overwrite a file.

My existing coding is ...
'Save the file
ActiveWorkbook.SaveAs Filename:=fsn

Your guidance and help is appreciated and gives me more
knowledge.

Best regards, Mike
mailto:[email protected]
 
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=fsn
Application.DisplayAlerts = True
 
Mike G. said:
I want my script to automatically reply "YES" when
prompted if I wish to overwrite a file.

No, you don't want the question there in the first place:

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=fsn
Application.DisplayAlerts = True

HTH. Best wishes Harald
 
Thanks
-----Original Message-----


No, you don't want the question there in the first place:

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=fsn
Application.DisplayAlerts = True

HTH. Best wishes Harald


.
 
Thanks
-----Original Message-----
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=fsn
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy




.
 
While the Guru's and Experts are pondering this one, I can
offer a suggestion. Get the name of the file to save as,
delete it if it exists, then save yours. Like this:

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\MyFiles\")
For Each file In f.Files
If file.Name = "fsn" Then
fso.DeleteFile "C:\MyFiles\fsn"
End If
Next file
 

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