xlpstatehelpers.h contains classes which control and maintain Excel's state across macro operations.
All the classes follow a similar pattern. They each save the state of an Excel property when they are constructed, and restore it when they are destroyed. They can thus be instantiated as local variables before operations that may change the state of the property, and the state will be restored at the end of the function, when the object goes out of scope.
The table below lists the classes declared in the header file.
Class | Description |
---|---|
CXlSuspendAutoRecalculation | Sets Calculation to Manual, and restores it to its previous value on destruction. |
CXlSuspendEcho | Suspends update of Excel's display, and restores it on destruction of all instances. |
CXlSuspendError | Suspends the display of Excel's alert dialogs, and restores it on destruction of all instances. |
CXlActiveCellRestorer | Saves and restores the active cell in a worksheet. |
CXlActiveSheetRestorer | Saves and restores the active sheet in a workbook. |
CXlActiveBookRestorer | Saves and restores the active workbook in an application. |