Skip to content

add a context manager to easily "freeze" excel when running code #254

@sdementen

Description

@sdementen

It is often useful to freeze excel while running some code, freeze in the sense of disabling (=setting to False):

  • Application.ScreenUpdating
  • Application.EnableEvents
  • Application.DisplayAlerts
  • setting calculation mode to manual

A nice API would be a simple context_manager in the vein of:

with app.freeze(events=True, screen=True, alerts=True, calculation=True):
    ... do some expensive changes in a workbook ...

that would save the status of these variables, change them according to the flags, yield and then set back the variables back to their original status.

Any feedback on the API ? if ok, i'll do a PR for the Windows version (I have no experience nor access to a Mac)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions