VBA to save a file copy as a backup (.XLK) file to another location

mrpaw

Board Regular
Joined
Jan 31, 2011
Messages
80
Hi all. I need to autosave a backup copy of a critical file to another location. I cannot use the default location even though the file name clearly states BACKUP and has warning messages when opened. For some reason users will still try to use those files. I have looked at file format enumerations but don't see one for backup files .XLK. How would I convert the following to use .XLK and what FileFormat?

Code:
ActiveWorkbook.SaveAs Filename:="R:\All\Level2\BACKUP\" & Nameit & ".xlsm", FileFormat:= _
        xlOpenXMLWorkbookMacroEnabled, CreateBackup:=True
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
.
Paste this into a Routine Module :

Code:
Option Explicit


Sub SaveMyWorkbook()
         
    Dim strPath As String
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    strPath = "C:\Users\My\Desktop\Backup.xlk"
    ActiveWorkbook.SaveAs Filename:=strPath
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
     
End Sub
 
Upvote 0
Perfect. Thank you. From all the searching I did, I'm sure I'm not the only person that could use this solution. It works PERFECTLY! Thank you again.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top