{"id":2091,"date":"2026-05-29T07:06:00","date_gmt":"2026-05-28T23:06:00","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2091"},"modified":"2026-03-28T06:22:11","modified_gmt":"2026-03-28T06:22:11","slug":"how-to-use-applicationdisplayrecentfiles-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationdisplayrecentfiles-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.DisplayRecentFiles in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>DisplayRecentFiles<\/code> property of the <code>Application<\/code> object in Excel&#8217;s object model controls whether the list of recently used files is shown in the Excel application&#8217;s backstage view (accessible via the File menu). In xlwings, a Python library for interacting with Excel, you can access and manipulate this property to customize the user interface experience programmatically. This can be useful in automation scripts where you want to streamline the Excel environment by hiding or showing recent files based on specific workflows or user preferences.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Functionality:<\/strong><br>The <code>DisplayRecentFiles<\/code> property is a Boolean value that determines the visibility of the recent files list. When set to <code>True<\/code>, Excel displays the list of recently opened documents; when set to <code>False<\/code>, the list is hidden. This property affects the Excel application globally, meaning it applies to all workbooks open in that instance of Excel. It is part of the application-level settings and can be used to enhance security or reduce clutter in user interfaces, especially in controlled corporate environments or automated reporting tools.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax in xlwings:<\/strong><br>In xlwings, you access the <code>Application<\/code> object through the <code>app<\/code> property of a workbook or by creating an instance of the Excel application. The <code>DisplayRecentFiles<\/code> property is exposed as an attribute that can be read or written. The syntax is straightforward:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to the active Excel instance or start a new one\napp = xw.apps.active # or xw.App() for a new instance\n\n# Get the current value of DisplayRecentFiles\ncurrent_setting = app.api.DisplayRecentFiles\n\n# Set DisplayRecentFiles to a new value\napp.api.DisplayRecentFiles = False # Hides the recent files list<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Note: The <code>api<\/code> property in xlwings provides direct access to the underlying Excel object model, allowing you to use properties and methods as defined in Excel&#8217;s VBA documentation. For <code>DisplayRecentFiles<\/code>, no parameters are required\u2014it is a simple read\/write property.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Code Examples:<\/strong><br>Here are practical xlwings API code snippets demonstrating the use of <code>DisplayRecentFiles<\/code>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Check and Report the Current Setting:<\/strong><br>This example retrieves the current state of <code>DisplayRecentFiles<\/code> and prints a message based on its value.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to Excel\napp = xw.apps.active\n\n# Get the property value\nis_displayed = app.api.DisplayRecentFiles\nif is_displayed:\n    print(\"The recent files list is currently visible in Excel.\")\nelse:\n    print(\"The recent files list is hidden.\")<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Toggle the Visibility of Recent Files:<\/strong><br>This script toggles the <code>DisplayRecentFiles<\/code> setting, switching it from its current state to the opposite. It can be used in a macro or automated task to dynamically adjust the UI.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\napp = xw.apps.active\n# Toggle the property\napp.api.DisplayRecentFiles = not app.api.DisplayRecentFiles\nprint(f\"DisplayRecentFiles toggled to: {app.api.DisplayRecentFiles}\")<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Hide Recent Files for a Clean Interface:<\/strong><br>In an automation scenario where you want to present a distraction-free Excel environment\u2014for instance, when generating reports\u2014you can set <code>DisplayRecentFiles<\/code> to <code>False<\/code> at the start and restore it later.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\napp = xw.apps.active\n# Save the original setting\noriginal_setting = app.api.DisplayRecentFiles\n\n# Hide the recent files list\napp.api.DisplayRecentFiles = False\nprint(\"Recent files list hidden. Perform your tasks here...\")\n\n# Restore the original setting (optional)\napp.api.DisplayRecentFiles = original_setting\nprint(\"Original setting restored.\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `DisplayRecentFiles` property of the `Application` object in Excel&apos;s object model controls wheth&#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-2091","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2091","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=2091"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2091\/revisions"}],"predecessor-version":[{"id":3200,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2091\/revisions\/3200"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}