{"id":2030,"date":"2026-04-28T15:49:32","date_gmt":"2026-04-28T07:49:32","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2030"},"modified":"2026-03-28T05:24:39","modified_gmt":"2026-03-28T05:24:39","slug":"how-to-use-applicationaltstartuppath-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationaltstartuppath-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.AltStartupPath in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <strong>AltStartupPath<\/strong> property of the <strong>Application<\/strong> object in Excel is a read\/write string property that sets or returns the full path to an alternate startup folder. This folder is used by Excel to store and locate files, such as templates, add-ins, or other workbooks, that should be automatically loaded when Excel starts. The primary startup folder is specified by the <strong>StartupPath<\/strong> property, but the <strong>AltStartupPath<\/strong> provides a secondary, user-defined location. This is particularly useful for managing different sets of startup files for various projects or user profiles without interfering with the default Excel startup configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In xlwings, you can access this property through the <code>xlwings.App<\/code> object, which represents the Excel application. The property is exposed as a Python attribute, allowing you to get or set its value directly. The syntax for accessing the <strong>AltStartupPath<\/strong> property in xlwings is straightforward: you use the <code>app<\/code> instance (representing the Application object) and reference <code>.api.AltStartupPath<\/code>. This provides a bridge to the underlying Excel object model. Here is the basic syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>To get the current alternate startup path:<\/strong><br><code>alt_path = app.api.AltStartupPath<\/code><br>This returns a string containing the full path, or an empty string if no alternate startup path is set.<\/li>\n\n\n\n<li><strong>To set a new alternate startup path:<\/strong><br><code>app.api.AltStartupPath = \"C:\\\\Your\\\\Folder\\\\Path\"<\/code><br>You must provide a valid folder path as a string. Note that backslashes in Windows paths should be escaped (e.g., <code>\"C:\\\\Folder\"<\/code>) or you can use raw strings (e.g., <code>r\"C:\\Folder\"<\/code>).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The property does not accept parameters beyond the path string itself. It is important to ensure that the specified folder exists and has appropriate permissions; otherwise, Excel may ignore it or throw an error. The <strong>AltStartupPath<\/strong> is persistent across Excel sessions if saved in a workbook or template, but setting it via xlwings only affects the current instance unless explicitly saved.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some practical xlwings code examples demonstrating the use of <strong>AltStartupPath<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Retrieving the Current Alternate Startup Path:<\/strong><br>This example connects to a running Excel instance, retrieves the alternate startup path, and prints it.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.apps.active # Get the active Excel application\nalt_startup_path = app.api.AltStartupPath\nprint(f\"Alternate Startup Path: {alt_startup_path}\")<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Setting a New Alternate Startup Path:<\/strong><br>This example sets a new alternate startup folder and then verifies the change by retrieving it.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.App(visible=True) # Start a new Excel application\nnew_path = r\"C:\\MyExcelStartupFiles\" # Use a raw string for Windows path\napp.api.AltStartupPath = new_path\n# Verify the setting\nupdated_path = app.api.AltStartupPath\nprint(f\"Updated Alternate Startup Path: {updated_path}\")\n# Save the setting by saving a workbook or closing properly\napp.quit()<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Checking and Using the Alternate Startup Path for File Operations:<\/strong><br>This example checks if an alternate startup path is set, and if so, lists the files in that folder.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\nimport os\napp = xw.apps.active\nalt_path = app.api.AltStartupPath\nif alt_path and os.path.exists(alt_path):\n    files = os.listdir(alt_path)\n    print(f\"Files in Alternate Startup Path: {files}\")\nelse:\n    print(\"No valid alternate startup path set.\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The **AltStartupPath** property of the **Application** object in Excel is a read\/write string proper&#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-2030","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2030","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=2030"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2030\/revisions"}],"predecessor-version":[{"id":3102,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2030\/revisions\/3102"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}