Can anyone help me, I have the two below codes, but I do not know how to put them together to work to save a backup of a Macro Enabled Workbook,
At present I am using the 1st code but it only saves as a normal workbook and all my macros will not work.
All I want is to be able to press a button and a backup of the file is saved in the specific location.
This is the instruction I have been given, but I have no idea how to make this work.
Put that code after Dim fName as String
and add highlighted part in old code.
.SaveAs Filename:="C:\users\sergej" & Fname & sExt
If anyone can give me an exact code or a better way of doing what I want, I would be very grateful.
Shazz
xx
At present I am using the 1st code but it only saves as a normal workbook and all my macros will not work.
All I want is to be able to press a button and a backup of the file is saved in the specific location.
Code:
Private Sub CommandButton1_Click() ' if you need to get FileName somewhere out
Dim Fname As String
Fname = "2017 Holiday Register Backup" 'change filename here
ActiveSheet.Copy
With ActiveWorkbook
' change adress
.SaveAs Filename:="Z:\STAFF HOLIDAY CHARTS\Archived & Backups\" & Fname
.Close
End With
End Sub
Code:
Dim sExt as String
'Determine FileFormat to SaveAs
Select Case ThisWorkbook.FileFormat
Case 56: sExt = ".xls" 'xlExcel8
Case 52: sExt = ".xlsm" 'xlOpenXMLWorkbookMacroEnabled
Case 50: sExt = "xlsb" 'xlExcel12
Case Else
MsgBox "Unable to determine file format; exiting...", vbInformation, vbNullString
Exit Sub
End Select
This is the instruction I have been given, but I have no idea how to make this work.
Put that code after Dim fName as String
and add highlighted part in old code.
.SaveAs Filename:="C:\users\sergej" & Fname & sExt
If anyone can give me an exact code or a better way of doing what I want, I would be very grateful.
Shazz
xx