{"id":2164,"date":"2026-07-04T16:19:06","date_gmt":"2026-07-04T08:19:06","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2164"},"modified":"2026-03-28T09:16:38","modified_gmt":"2026-03-28T09:16:38","slug":"how-to-use-applicationproductcode-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationproductcode-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.ProductCode in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <strong>ProductCode<\/strong> property of the <strong>Application<\/strong> object in Excel&#8217;s object model is a read-only property that returns a globally unique identifier (GUID) for the installed Microsoft Excel product. This GUID is a string that uniquely identifies the specific version and edition of Excel, such as whether it is a retail, volume-licensed, or OEM version. This property is particularly useful for developers and system administrators who need to programmatically identify or verify the Excel installation on a machine, for example, in software deployment, licensing checks, or compatibility validations within automated scripts or applications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In xlwings, the <strong>Application<\/strong> object is accessed through the <code>app<\/code> property of a <code>Book<\/code> object or directly when starting an application. The <strong>ProductCode<\/strong> property can be called as an attribute on the <code>app<\/code> object. The syntax is straightforward, as it does not take any parameters:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>product_code = app.api.ProductCode<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, <code>app<\/code> refers to the xlwings <code>App<\/code> instance, and <code>.api<\/code> is used to access the underlying Excel Application object from the COM interface. The property returns a string representing the ProductCode GUID. Note that this property is specific to the Excel application instance, so it will reflect the version of Excel that xlwings is connected to.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, to retrieve the ProductCode of an active Excel instance using xlwings, you can use the following code. This example assumes Excel is already running or will be started by xlwings:<\/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 if xw.apps.active else xw.App(visible=True)\n\n# Get the ProductCode property\nproduct_code = app.api.ProductCode\nprint(f\"Excel ProductCode: {product_code}\")\n\n# Optionally, close the app if it was started for this purpose\nif not xw.apps.active:\n    app.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this code, <code>xw.apps.active<\/code> is used to attach to an existing Excel application; if none exists, a new one is created with <code>xw.App(visible=True)<\/code>. The <code>app.api.ProductCode<\/code> call retrieves the GUID, which is then printed. The GUID typically looks something like <code>{90160000-0011-0000-1000-0000000FF1CE}<\/code> for an Office 2016 version, but it varies by installation. This output can be used to identify the Excel product programmatically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Another practical use case is to check the ProductCode in a script that requires a specific Excel version. For instance, you might want to ensure compatibility before proceeding with automation tasks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\napp = xw.apps.active if xw.apps.active else xw.App(visible=False)\nexpected_product_code = \"{90160000-0011-0000-1000-0000000FF1CE}\" # Example for Office 2016\n\nif app.api.ProductCode == expected_product_code:\n    print(\"Compatible Excel version detected. Proceeding with automation.\")\n    # Add your automation code here\nelse:\n    print(f\"Incompatible Excel version. ProductCode: {app.api.ProductCode}\")\n\napp.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The **ProductCode** property of the **Application** object in Excel&apos;s object model is a read-only pr&#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-2164","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2164","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=2164"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2164\/revisions"}],"predecessor-version":[{"id":3310,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2164\/revisions\/3310"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}