A macro that automatically executes when the Worksheet is unloaded
#DEFINE $DEINITWKS body
body - an expression to execute when the Worksheet is unloaded.
#define $initwks toolbar(1, -1, 4, "Noise", "rand(10)")
#define $deinitwks toolbar(1, -1, 8)
Defines $INITWKS to add a button to the main toolbar that creates a 10x10 array of random noise. Because the $INITWKS macro is saved with the Worksheet, the toolbar button will be added when the Worksheet is loaded.
$DEINITWKS is defined to remove the added button. Because the $DEINITWKS macro is saved with the Worksheet, the added toolbar button will be removed each time the Worksheet is unloaded.
$INITWKS and $DEINITWKS allow a Worksheet to be dynamically customized.
Any valid expression, including SPL routines, can be assigned to $INITWKS and $DEINITWKS.
See $INITWKS for a macro that executes when a Worksheet is loaded.