Autosave Excel file using code to protect file

Lot of time many peoples facing these issue like computer crashes, power goes out, accidentally close any file without saving and many more. In that situation you may lost of your working data, and you need to know how to autosave Excel file. There are lot of ways to auto save Excel file either using Autosave feature or using the code.

All we know due to sudden crashes we accidentally lost our important excel sheet data. To avoid the losing of your important data, you must have to take care. To do this job either you can choose AutoSave or AutoRecovery option. You can also use code for quickly auto save Excel file.

In this article we have to discuss how could you auto save your excel file without any additional effort.

Automatically open a specific Excel file whenever you start Excel

How to Autosave Excel file using code

To protect your file in case of any crashes you must have to know how to autosave Excel file using code.

Autosave Excel file

Step 1: Open a new file in which you want to apply the code to auto save Excel file.

Step 2: Click right mouse button of Sheet 1 tab in active workbook and choose View Code option.

Step 3: Under the VBA Project select “ThisWorkbook” option. Press right mouse button on “ThisWorkbook” option and click on the “View Code” option.

Step 4: In open ThisWorkbook (Code) window and choose “Workbook” option. In right pan click on the drop down arrow and choose “BeforeClose” option.

Step 5: Now remove the previous code and type the following given code in active code window.
“” and either press button click in the active window or press tab key.
Private Sub Workbook_BeforeClose (Cancel As Boolean)
End Sub

After typing the code don’t close the active window and go back to the Sheet1. Now, save the active workbook as a “Excel Macro-Enabled Workbook”. Again reopen the Macro-Enable workbook in you system. When you open the file Excel shows a security warning message. You just click on the “Enable Content” option.

How to use latest Quick Analysis feature in Excel

Step 6: Now, insert or delete any data or make any required changes in active sheet. After finish the modification directly click on the close window without saving the changes. Again when you re-open the file all changes are properly shown in the active file.

How to AutoSave Excel File

To enable AutoSave Excel file you must have to take few given simple steps.

Step 1: Click on the File menu > Options > Choose Save option.

Step 2: Make sure the Save AutoRecover information every …. minutes box is selected. If not then set the time interval as per your need. You can also turn on “Keep the last autosaved version if i close without saving” option. Now, click on the OK button to close the Excel Option dialog box.

Leave a Reply

Your email address will not be published. Required fields are marked *