Hi all.
I have an add-in that currently retrieves user settings from an external file and stores them in a worksheet (within the add-in) for later use. It works but seems like a cumbersome way of doing it.
I'm expanding my use of Class Modules and need somebody to help me clarify something.
I've written a Class that can store the details of a setting (name, value, default). Then I've written a class which will serve as a collection of those settings.
What is the lifetime of the classes?
I get that lifetime and scope are closely related, but they're not the same. In the example of a procedure level "Static" vs "Dim", the scope is the same, that it can only be used in the procedure it was defined, but their lifetime is different. The lifetime of Dim will end when the procedure ends, the lifetime of Static will end when the macro ends, which means it will keep it's value between calls to the procedure it is defined in.
My add-in is controlled by a Ribbonx Ribbon. There are various "tools" in the add-in that use lots of the same procedures as each other. When a tool is launched from the ribbon by the user, the selected macro executes, it accesses the values that were saved to the settings worksheet when the add-in loaded, it does it's thing, then it ends.
Any other variable would be destroyed once the macro ends so each tool needs to read in the settings again upon launch. But because the add-in is still loaded, are my class variables still filled with data? If I was to replace the bit where a macro accesses the settings worksheet with accessing a class variable, would it work?
What I want to do is get rid of the need to keep a worksheet holding the settings while the add-in is loaded. I want to import from the external file straight to the collection and then have that collection available at all times to any module (add-in "tool") that needs to use it.
Not entirely sure I'm making myself clear on this one. I'm happy to clarify if you can help.
Cheers.
Bookmarks