I have created an Excel ribbon addin which needs to persist user selections between Excel sessions. Using custom XML Parts seems to be the best option for this. However I can’t get this to work without getting COMExceptions.
The MSDN docs are just not very useful (http://msdn.microsoft.com/en-us/library/bb608612.aspx). Can someone give me an example of making this work in an Excel Ribbon addin?
There are three different methods I know of:
Custom XML parts
For an application-level add in, this is my preferred method of storing any application data that needs to be persisted in a saved xls file without ever being visible to the user.
http://msdn.microsoft.com/en-us/library/bb608612.aspx
Cached Data Islands
This only works for document-level add ins. You will get exceptions if you try to use it in an application-level add in.
http://blogs.msdn.com/b/eric_carter/archive/2004/04/23/119294.aspx
Hidden worksheet
Using VSTO, you can create invisible worksheets that cannot be seen by users. This works well, but leads to a lot of awkward coding to convert your data to fit in an excel sheet.
Update (2014):
So in the end the usage of Custom XML parts turned out to be a performance issue so my application had to be changed back to use hidden worksheets. Apparently, once the XML reaches a certain size, Excel becomes very sluggish. My add-in had Custom Parts reach thousands of nodes, and the larger the XML grew, the slower everything in Excel became. For example, simply clicking on any cell would incur a very noticeable delay.