
- and then start writing the code for of auto save in excel.

- “ThisWorkbook.Save” will automatically save the workbook and save it as a macro-enabled workbook to run the code like this:

- Save this workbook as a macro-enabled and close the workbook. Then we can observe that display alert asking for save or don’t save won’t get pop out but some other warning alert will pop out which is as below:
- Once you click on OK, the workbook with changes will get auto saved. We can also disable this alert by using some code in VBA which saves a workbook automatically in a simple way.
- Like this,
-

- These warning messages will come through an application so we take “Application.DisplayAlerts = False”. This means any sort of display alert will not pop out once this line is included in the code. But it also important to include a line of “Application.DisplayAlerts = True” as this helps when something important display alert to pop out.
- Now try to make changes and close the workbook, we can observe that none of the display alerts will pop out but changes will get saved. This operation will help us in order to save our work though we unexpectedly close the workbook without saving it.


No comments:
Post a Comment