I have looked through the forum for an answer to this but I could not find one. Is there a way to use SaveAs without having to select Yes to overwrite files that already exist?
Revise: I figured a way around the problem by detecting and deleting a file by the name of the file you are trying to save.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Creates a file system object with which to manipulate files
Set fs = CreateObject("Scripting.FileSystemObject")
'The file name you want to save as
FName = "file name"
'Detects if the file already exists and if so deletes it
If fs.FileExists(FName) Then fs.DeleteFile (FName)
ThisWorkbook.SaveAs Filename:=FName
End Sub
Bookmarks