IApplicationState

Defines the public contract for the ApplicationState class, exposing busy-state toggling and snapshot capture of Excel Application settings. Callers apply a locked-down busy mode (no screen updates, manual calc, alerts off) and later restore the original state from the snapshot.

Busy State

ApplyBusyState #

Transition to busy state

Signature:

Public Sub ApplyBusyState(Optional ByVal suppressEvents As Boolean = False, _
                          Optional ByVal calculateOnSave As Boolean = True, _
                          Optional ByVal busyCursor As Long = 0, _
                          Optional ByVal blockSecurity As Boolean = False)

Transition to and from the busy state. Applies busy settings (ScreenUpdating False, DisplayAlerts False, Calculation Manual, EnableAnimations False when available) over the captured application snapshot.

Parameters:

  • suppressEvents: Boolean. When True, disables Application.EnableEvents. Defaults to False.
  • calculateOnSave: Boolean. Value for CalculateBeforeSave. Defaults to True.
  • busyCursor: Long. Cursor shown while busy. When 0 (default), leaves cursor unchanged.
  • blockSecurity: Boolean. When True, forces AutomationSecurity to msoAutomationSecurityForceDisable. Defaults to False.

Restore #

Restore the application to its pre-busy state

Signature:

Public Sub Restore()

Restores all captured application settings, even when ApplyBusyState was never called. Clears the busy flag.


RefreshSnapshot #

Refresh the stored snapshot with current application values

Signature:

Public Sub RefreshSnapshot()

Re-captures the application state so subsequent Restore invocations return to the freshly captured values. Cannot be called while busy.


Introspection

ApplicationObject #

Application reference currently guarded

Signature:

Public Property Get ApplicationObject() As Application

Read-only state accessors.

Returns: Application. The Excel Application instance.


IsBusy #

Whether the busy state is currently active

Signature:

Public Property Get IsBusy() As Boolean

Returns: Boolean. True when ApplyBusyState has been invoked without a matching Restore.


HasSnapshot #

Whether a snapshot exists and restoration is possible

Signature:

Public Property Get HasSnapshot() As Boolean

Returns: Boolean. True when a snapshot has been captured.