Saving Changes

Another potential problem with an Add-in that contains data is that changes to the data will not be saved automatically at the end of an Excel session. For example, Addin.xlam allows users to edit the data in the range Database, so it is essential to save those changes before the Add-in is closed. One of the nice things about Add-ins is that users are never bothered with prompts about saving changes. Therefore, you need to ensure that data is saved by setting up a procedure in your VBA code. One way to do this is to add the following code to the Workbook_BeforeClose event procedure, or the Auto_Close procedure:

If Not ThisWorkbook.Saved Then ThisWorkbook.Save

0 0

Post a comment