In Hiding data in Excel Objects I introduced the concept of hiding data in shapes by encoding it into jSon, then hiding the serialized result in a property of a hidden shape. One of the common uses of this to enable data persistence between calls to a userForm.
I have introduced a new class, cPersistence, which is used to store and load what was in a form from one session to the next. Typically you would populate the form on activation , and store the current values on deactivation like this. This example is in the cDataSet.xlsm example in Downloads
and that's all there is to it.
Lets take a simple form like this
We'd like to use as default whatever was previously entered the last time the form was used. So after filling in this data, and closing the form, the next time the form comes up we want to see those previous values as default like this
The cPersistence class will take a form, serialize the data on each field in the form, store it in an invisible shape in the workbook somewhere on exit, and do the reverse when you open the form.
Here is what gets stored when closing the above form
You just need to delete the container shape
Here is the code for the cPersistence class
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Recursion > Hiding data in Excel Objects >