• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Create Backup Copy using Excel VBA

game_federer

New Member
Hi All,

I wanted to create a backup copy before I run the subroutines Ive written for my file.
Ive used the following code.

Code:
path_new = ActiveWorkbook.Path
    ActiveWorkbook.SaveAs Filename:=path_new & "\Backup_Copy"

The problem is it closes the original file and runs the macros created on the backup copy.
Your help would be greatly appreciated.
 
Hello
Try this code
Code:
Sub Auto_Save()
    Dim saveDate As Date
    Dim saveTime As Variant
    Dim formatTime As String
    Dim formatDate As String
    Dim backupFolder As String

    saveDate = Date
    saveTime = Time

    formatTime = Format(saveTime, "hh.MM.ss")
    formatDate = Format(saveDate, "DD - MM - YYYY")

    Application.DisplayAlerts = False
        backupFolder = ThisWorkbook.Path & "\"
        ActiveWorkbook.SaveCopyAs Filename:=backupFolder & Replace(ActiveWorkbook.Name, ".xlsm", "") & " " & formatDate & " " & formatTime & ".xlsm"
    Application.DisplayAlerts = True

    MsgBox "Backup Successfully In The Path " & backupFolder
End Sub
 
Hello
Try this code
Code:
Sub Auto_Save()
    Dim saveDate As Date
    Dim saveTime As Variant
    Dim formatTime As String
    Dim formatDate As String
    Dim backupFolder As String

    saveDate = Date
    saveTime = Time

    formatTime = Format(saveTime, "hh.MM.ss")
    formatDate = Format(saveDate, "DD - MM - YYYY")

    Application.DisplayAlerts = False
        backupFolder = ThisWorkbook.Path & "\"
        ActiveWorkbook.SaveCopyAs Filename:=backupFolder & Replace(ActiveWorkbook.Name, ".xlsm", "") & " " & formatDate & " " & formatTime & ".xlsm"
    Application.DisplayAlerts = True

    MsgBox "Backup Successfully In The Path " & backupFolder
End Sub
Thanks YK for this code.
Helped me a ton and my client was very happy with it. :)
 
Back
Top