I am wanting to create a backup file to my backup directory the close that file. I then want to save and the close the current workbook. Then close the Excel Application. I am having trouble closing the backup file and at the end closing Excel.
All help is greatly appreciated.
Terry
VBA Code:
'/-------------------------------------------------------------
'/ Main total worksheet(23-24) save and close button
'/-------------------------------------------------------------
Sub SaveAndClose()
Dim BUFileName As String '/ Declaring file path name
Dim MyName As String '/ Declaring file name
Current_date = Format(Now, "MMDDYY_hhmmss") '/ Assigning date & Time to use in file name
'/---------------------------------------------------------------
'/ Turning off notifications for savings and closing
'/---------------------------------------------------------------
Application.DisplayAlerts = False
Application.EnableEvents = False
'/---------------------------------------------------------------
'/ Creating a backup file and then closing it
'/---------------------------------------------------------------
MyName = ActiveWorkbook.Name '/ Assigning file name of current active workbook
BUFileName = "G:\TECH\ib271t0o\MyBackups\" & MyName & "-" & Current_date & ".xlsm" '/ Buliding full path name for backup file
ActiveWorkbook.SaveAs FileName:=BUFileName '/ Saving backup file
Workbooks("G:\TECH\ib271t0o\MyBackups\" & MyName & "-" & Current_date & ".xlsm" ).Close
'/---------------------------------------------------------------
'/ Turning off notifications for savings and closing
'/ Saving any changes
'/ closeing this workbook
'/---------------------------------------------------------------
ThisWorkbook.Save
Application.Quit
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub
All help is greatly appreciated.
Terry