{"id":2036,"date":"2026-05-01T16:30:01","date_gmt":"2026-05-01T08:30:01","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2036"},"modified":"2026-03-28T05:30:16","modified_gmt":"2026-03-28T05:30:16","slug":"how-to-use-applicationautocorrect-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationautocorrect-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.AutoCorrect in the xlwings API way"},"content":{"rendered":"\n<p>The AutoCorrect feature in Excel is a powerful tool for automatically correcting common typing errors, capitalizing days of the year, and expanding text abbreviations. Through xlwings, you can programmatically access and control these settings via the <code>Application<\/code> object&#8217;s <code>AutoCorrect<\/code> property. This allows for automation of tasks such as disabling auto-capitalization of days, adding custom replacement entries, or checking if a specific text string is in the AutoCorrect list.<\/p>\n\n\n\n<p><strong>Functionality<\/strong><br>The <code>AutoCorrect<\/code> object provides control over Excel&#8217;s AutoCorrect options. Key capabilities include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Managing automatic capitalization of days of the week.<\/li>\n\n\n\n<li>Controlling the first letter capitalization in sentences.<\/li>\n\n\n\n<li>Adding, removing, or checking text replacements (e.g., replacing &#8220;(c)&#8221; with &#8220;\u00a9&#8221;).<\/li>\n\n\n\n<li>Enabling or disabling various auto-formatting features.<\/li>\n<\/ul>\n\n\n\n<p><strong>Syntax and Parameters<\/strong><br>In xlwings, you access it through the <code>app<\/code> object (an instance of <code>xw.App<\/code>). The basic syntax is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app.api.AutoCorrect.MemberName<\/code><\/pre>\n\n\n\n<p>Where <code>MemberName<\/code> is a property or method of the AutoCorrect object. Common members include:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Member<\/th><th>Type<\/th><th>Description<\/th><th>Parameters\/Values<\/th><\/tr><\/thead><tbody><tr><td><code>CapitalizeNamesOfDays<\/code><\/td><td>Property<\/td><td>Gets or sets whether days are auto-capitalized.<\/td><td>Boolean (<code>True<\/code>\/<code>False<\/code>)<\/td><\/tr><tr><td><code>TwoInitialCapitals<\/code><\/td><td>Property<\/td><td>Controls auto-correction of two initial capitals.<\/td><td>Boolean<\/td><\/tr><tr><td><code>AddReplacement(What, Replacement)<\/code><\/td><td>Method<\/td><td>Adds a custom text replacement.<\/td><td><code>What<\/code> (String): Text to replace. <code>Replacement<\/code> (String): New text.<\/td><\/tr><tr><td><code>DeleteReplacement(What)<\/code><\/td><td>Method<\/td><td>Removes a custom replacement.<\/td><td><code>What<\/code> (String): Text entry to delete.<\/td><\/tr><tr><td><code>ReplacementList(Index)<\/code><\/td><td>Property<\/td><td>Returns a specific replacement pair.<\/td><td><code>Index<\/code> (Integer): Position in the list (1-based).<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Code Examples<\/strong><br>Here are practical examples using xlwings:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Disable auto-capitalization of days:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.App(visible=False)\napp.api.AutoCorrect.CapitalizeNamesOfDays = False\napp.quit()<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Add a custom text replacement:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.App(visible=False)\n# Replace \"xlw\" with \"xlwings\"\napp.api.AutoCorrect.AddReplacement(\"xlw\", \"xlwings\")\napp.quit()<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Check and delete a replacement:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.App(visible=False)\n# Delete if \"xlw\" exists in the list\ntry:\n    app.api.AutoCorrect.DeleteReplacement(\"xlw\")\n    print(\"Replacement deleted.\")\nexcept Exception as e:\n    print(\"Entry not found:\", e)\napp.quit()<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Iterate through replacement list (first 5 entries):<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.App(visible=False)\nac = app.api.AutoCorrect\nfor i in range(1, 6):\ntry:\n    item = ac.ReplacementList(i)\n    print(f\"Index {i}: {item}\")\nexcept:\n    break\napp.quit()<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The AutoCorrect feature in Excel is a powerful tool for automatically correcting common typing error&#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-2036","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2036","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=2036"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2036\/revisions"}],"predecessor-version":[{"id":3112,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2036\/revisions\/3112"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}