kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim backupfolder As String
backupfolder = "C:\BackupFile\"
ThisWorkbook.SaveCopyAs Filename:=backupfolder & ThisWorkbook.Name
End Sub
Hi,
The above code is what I am using to create a backup of my data. I want it to override the file inside that backupfolder but it won't and hence throws an error. With three suggested reasons of which I fall into one; file already exists
So I am thinking of two options here:
1. Override it if possible with vba
2. Delete the previous file before creating new
Thanks in advance