Results 1 to 4 of 4

Save backup of workbook before close

Threaded View

  1. #1
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Save backup of workbook before close

    I was hoping somebody had a suggestion for how to solve this backup question.

    I call the macro below from a Workbook_BeforeClose sub; however, if the user has not saved changes before they hit the close then the Sub SaveFile runs and then after the backup save they are then asked do you want to save changes.

    I initially had this sub run with Workbook_BeforeSave, but I don't really want to run this everytime the user selects save.

    Any ideas on how to how the save changes first and then the backup?

    Sub SaveFile()
    
    Dim Ans As Integer
    Dim Filt As String
        
        Ans = MsgBox("Confirm you want to save this File." _
        & (Chr(13) & Chr(10)) & (Chr(13) & Chr(10)) & _
        "File will save as: Backup - (SheetNumber).xls in current directory", vbYesNo)
    
    If Ans = vbNo Then Exit Sub
        Application.DisplayAlerts = False
            ThisWorkbook.SaveCopyAs Filename:=ActiveWorkbook.Path & "\Backup - " & ThisWorkbook.Name
        Application.DisplayAlerts = True
        ThisWorkbook.Close
    End Sub
    Last edited by jeffreybrown; 12-16-2009 at 10:41 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1