f EnableEvents property of the Application object is set to True then Excel
fires events. If EnableEvents is False then Excel does not fire events. There
is however additional complication. Consider the session on the picture.
We have set the Application.EnableEvents to False and then attempted to
execute another command. The ControlShell is not getting any response from the
addin inside the Excel application. This is not a bug. This is more an insight
on how ControlShell works. ControlShell is a standalone application that
accepts commands from the user and forces the Excel to generate a special
event via out-of-process COM protocol. The PFE addin inside the Excel catches
such special event and executes commands from the ControlShell in-process
until there is nothing left to do. Then the addin signals the completion to
the ControlShell and releases control of the Excel. However, in the present
situation Excel does not fire events. Hence, the PFE addin never gets control
and never signals to the ControlShell that the last command has been
completed. The ControlShell thinks that the PFE addin is still processing.
The above does not mean, however, that one cannot use the EnableEvents
property. This property may still be manipulated inside of a script placed in
a file (execfile or otherwise). Just make sure that EnableEvents is True
before the script exits.
If you find yourself in the above situation then you need to set EnableEvents
to True from "Immediate" window of VBA for Excel screen. Then kill the addin
shell in the ControlShell window by pressing <Ctrl>+<Delete> at
the waiting prompt. Consequently, you may resurrect it by pressing one of the
<Alt>+<Shift>+<Q>, <Alt>+<Shift>+<Z> from