{"id":2037,"date":"2026-05-02T07:14:45","date_gmt":"2026-05-01T23:14:45","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2037"},"modified":"2026-03-28T05:31:12","modified_gmt":"2026-03-28T05:31:12","slug":"how-to-use-applicationautoformatasyoutypereplacehyperlinks-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationautoformatasyoutypereplacehyperlinks-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.AutoFormatAsYouTypeReplaceHyperlinks in the xlwings API way"},"content":{"rendered":"\n<p>The <strong>AutoFormatAsYouTypeReplaceHyperlinks<\/strong> member of the <strong>Application<\/strong> object in Excel is a property that controls whether Excel automatically formats text that resembles a hyperlink address into a clickable hyperlink as you type. This is part of the &#8220;AutoFormat as you type&#8221; feature, which can help in quickly creating interactive documents by converting typed URLs or network paths into functional links without manual formatting. In xlwings, this property is accessible via the Application object&#8217;s API, allowing you to programmatically check or set this automation setting, which can be particularly useful in scripts that prepare or clean Excel workbooks for specific user interactions.<\/p>\n\n\n\n<p><strong>Syntax in xlwings:<\/strong><br>In xlwings, you interact with this property through the <code>app<\/code> object, which represents the Excel Application. The property is exposed as a boolean attribute. The syntax is straightforward:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app.api.AutoFormatAsYouTypeReplaceHyperlinks<\/code><\/pre>\n\n\n\n<p>This property can be both read and written. When reading, it returns <code>True<\/code> if the feature is enabled, and <code>False<\/code> if disabled. When writing, you can set it to <code>True<\/code> to enable automatic hyperlink formatting, or <code>False<\/code> to disable it. There are no additional parameters or arguments for this property, as it is a simple toggle.<\/p>\n\n\n\n<p><strong>Example Usage with xlwings:<\/strong><br>Below is a practical example demonstrating how to use the <code>AutoFormatAsYouTypeReplaceHyperlinks<\/code> property in a Python script with xlwings. This example checks the current setting, toggles it based on a condition, and then types some text to observe the effect (if Excel is visible). Note that changes to this setting may affect the user&#8217;s Excel session, so it&#8217;s often used in controlled environments or reset afterward.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Start or connect to an Excel application\napp = xw.App(visible=True) # Set visible=True to see the typing effect\nwb = app.books.add()\n\n# Access the AutoFormatAsYouTypeReplaceHyperlinks property\ncurrent_setting = app.api.AutoFormatAsYouTypeReplaceHyperlinks\nprint(f\"Current AutoFormatAsYouTypeReplaceHyperlinks setting: {current_setting}\")\n\n# Toggle the setting: enable if disabled, or disable if enabled\nnew_setting = not current_setting\napp.api.AutoFormatAsYouTypeReplaceHyperlinks = new_setting\nprint(f\"Setting changed to: {new_setting}\")\n\n# To see the effect, type a URL in a cell (requires Excel to be visible and active)\nif app.visible:\n    sheet = wb.sheets&#91;0]\n    sheet.range('A1').value = \"Visit https:\/\/www.example.com for more info.\"\n    # If enabled, Excel will format the URL as a hyperlink automatically as you type.\n    # Note: In xlwings, setting cell value programmatically may not trigger the \"as you type\" feature,\n    # as it simulates direct value insertion rather than keystroke-by-keystroke typing.\n    # The feature primarily works during manual typing in the Excel interface.\n\n    # Restore the original setting (optional, for user convenience)\n    app.api.AutoFormatAsYouTypeReplaceHyperlinks = current_setting\n\n# Save and close\nwb.save('hyperlink_example.xlsx')\nwb.close()\napp.quit()<\/code><\/pre>\n\n\n\n<p><strong>Important Notes:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>AutoFormatAsYouTypeReplaceHyperlinks<\/code> property affects the entire Excel application session, not just a specific workbook. Changing it will influence all open workbooks and future typing actions.<\/li>\n\n\n\n<li>In xlwings, when you set a cell&#8217;s value using <code>.value<\/code>, Excel may not apply the &#8220;as you type&#8221; formatting because it is not simulating real-time keystrokes. The feature is designed for manual entry in the Excel GUI. Therefore, toggling this property via xlwings is more about configuring the environment for user interaction rather than for programmatic data insertion.<\/li>\n\n\n\n<li>This property is part of Excel&#8217;s application-level options, so it&#8217;s persistent across sessions if saved in the user&#8217;s settings, but xlwings changes are temporary for the current session unless explicitly saved via Excel&#8217;s options dialog.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The **AutoFormatAsYouTypeReplaceHyperlinks** member of the **Application** object in Excel is a prop&#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-2037","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2037","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=2037"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2037\/revisions"}],"predecessor-version":[{"id":3114,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2037\/revisions\/3114"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}