{"id":2095,"date":"2026-05-31T07:39:26","date_gmt":"2026-05-30T23:39:26","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2095"},"modified":"2026-03-28T06:25:50","modified_gmt":"2026-03-28T06:25:50","slug":"how-to-use-applicationenableanimations-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationenableanimations-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.EnableAnimations in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <strong>EnableAnimations<\/strong> property of the <strong>Application<\/strong> object in Excel controls whether animation effects are displayed during certain operations, such as inserting or deleting rows\/columns, or applying filters. This property can be used to enhance performance by disabling animations, especially when automating repetitive tasks via xlwings, as it reduces screen flickering and speeds up macro execution. In xlwings, you can access this property through the <code>app<\/code> object, which represents the Excel application instance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax in xlwings:<\/strong><br><code>app.api.EnableAnimations<\/code><br>This property is a Boolean value:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>True<\/strong>: Enables animations (default in Excel).<\/li>\n\n\n\n<li><strong>False<\/strong>: Disables animations.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It can be both read and written. When setting it, assign <code>True<\/code> or <code>False<\/code> directly. Note that changes apply only to the current Excel session and do not persist after closing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example Usage:<\/strong><br>Below are xlwings code examples demonstrating how to use the <strong>EnableAnimations<\/strong> property:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Disabling animations to improve performance during data operations:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n# Connect to the active Excel instance\napp = xw.apps.active\n# Disable animations\napp.api.EnableAnimations = False\n# Perform operations, e.g., inserting rows\nsheet = app.books.active.sheets&#91;0]\nsheet.api.Rows(1).Insert()\n# Re-enable animations after completion\napp.api.EnableAnimations = True<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This code disables animations before inserting a row, reducing visual distraction and speeding up the action, then restores the default setting.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Checking the current animation status:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.apps.active\ncurrent_status = app.api.EnableAnimations\nprint(f\"Animations are enabled: {current_status}\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This reads the property to determine if animations are active, useful for conditional logic in scripts.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Using in a context manager for temporary control:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.apps.active\n# Store original setting\noriginal_setting = app.api.EnableAnimations\ntry:\n    app.api.EnableAnimations = False\n    # Execute multiple operations\n    sheet = app.books.active.sheets&#91;0]\n    for i in range(5):\n        sheet.api.Cells(i+1, 1).Value = f\"Data {i}\"\nfinally:\n    # Restore original setting\n    app.api.EnableAnimations = original_setting<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The **EnableAnimations** property of the **Application** object in Excel controls whether animation &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-2095","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=2095"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2095\/revisions"}],"predecessor-version":[{"id":3205,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2095\/revisions\/3205"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}