{"id":2105,"date":"2026-06-05T07:58:24","date_gmt":"2026-06-04T23:58:24","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2105"},"modified":"2026-03-28T07:05:38","modified_gmt":"2026-03-28T07:05:38","slug":"how-to-use-applicationexcel4intlmacrosheets-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationexcel4intlmacrosheets-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.Excel4IntlMacroSheets in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>Excel4IntlMacroSheets<\/code> property of the <code>Application<\/code> object in Excel&#8217;s object model is a legacy feature primarily used for backward compatibility with older Excel 4.0 international macro sheets. In xlwings, this property can be accessed to retrieve a collection of sheets that are specifically Excel 4.0 international macro sheets within a workbook. These sheets are a type of macro sheet that was used in earlier versions of Excel for storing macro commands and functions, particularly in international contexts where different language settings were involved. While modern Excel development typically uses VBA (Visual Basic for Applications) for macros, the <code>Excel4IntlMacroSheets<\/code> property remains available for compatibility reasons, allowing developers to interact with or reference these legacy components programmatically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In xlwings, the <code>Excel4IntlMacroSheets<\/code> property is accessed through the <code>app<\/code> object, which represents the Excel application. The syntax for using this property in xlwings is straightforward, as it returns a collection of sheet objects that correspond to the Excel 4.0 international macro sheets. The property does not take any parameters, making it simple to call. Here is the basic syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to the active Excel application\napp = xw.apps.active\n\n# Access the Excel4IntlMacroSheets property\nintl_macro_sheets = app.api.Excel4IntlMacroSheets<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this code, <code>app.api.Excel4IntlMacroSheets<\/code> calls the underlying Excel object model property via xlwings&#8217; <code>api<\/code> attribute, which provides direct access to Excel&#8217;s COM interface. The returned value is a collection that can be iterated over to access individual sheets. Each sheet in this collection is an object representing an Excel 4.0 international macro sheet, and you can use properties like <code>Name<\/code> to get the sheet&#8217;s name or <code>Visible<\/code> to check its visibility. Note that this property may return <code>None<\/code> or an empty collection if no such sheets exist in the workbook, so it&#8217;s good practice to handle such cases in your code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, to list all Excel 4.0 international macro sheets in the active workbook, you can use the following xlwings code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Start or connect to Excel\napp = xw.apps.active\n\n# Get the Excel4IntlMacroSheets collection\nintl_macro_sheets = app.api.Excel4IntlMacroSheets\n\n# Check if there are any sheets in the collection\nif intl_macro_sheets is not None and intl_macro_sheets.Count > 0:\n    for sheet in intl_macro_sheets:\n        print(f\"Sheet Name: {sheet.Name}, Visible: {sheet.Visible}\")\nelse:\n    print(\"No Excel 4.0 international macro sheets found.\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This code iterates through each sheet in the <code>Excel4IntlMacroSheets<\/code> collection and prints its name and visibility status. It includes error handling to account for cases where no such sheets are present. Additionally, you can perform operations on these sheets, such as activating them or reading data, though this is less common in modern workflows due to the deprecated nature of Excel 4.0 macros. For instance, to activate the first Excel 4.0 international macro sheet, you could use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if intl_macro_sheets is not None and intl_macro_sheets.Count > 0:\n    first_sheet = intl_macro_sheets(1) # Indexing starts at 1 in Excel\n    first_sheet.Activate()\n    print(f\"Activated sheet: {first_sheet.Name}\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `Excel4IntlMacroSheets` property of the `Application` object in Excel&apos;s object model is a legacy&#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-2105","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2105","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=2105"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2105\/revisions"}],"predecessor-version":[{"id":3222,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2105\/revisions\/3222"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}