View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Say 'YES' to overwrite file

Easier would be

On Error Resume Next
Kill "C:\MyFiles\fsn"
On Error goto 0

--
Regards,
Tom Ogilvy

"Tod" wrote in message
...
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


-----Original Message-----
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


.