{"id":2014,"date":"2026-04-20T16:49:20","date_gmt":"2026-04-20T08:49:20","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2014"},"modified":"2026-03-28T04:54:24","modified_gmt":"2026-03-28T04:54:24","slug":"how-to-use-applicationsharepointversion-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationsharepointversion-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.SharePointVersion in the xlwings API way"},"content":{"rendered":"\n<p>The <code>SharePointVersion<\/code> property of the <code>Application<\/code> object in Excel&#8217;s object model provides a read-only integer value that indicates the version of Microsoft SharePoint Foundation or Microsoft SharePoint Server that the current workbook is linked to, if it is stored on a SharePoint site. This property is particularly useful for developers who need to programmatically determine the SharePoint environment to implement version-specific features or compatibility checks when automating Excel through xlwings. In xlwings, this property is accessed via the <code>api<\/code> property, which exposes the underlying Excel object model.<\/p>\n\n\n\n<p><strong>Functionality:<\/strong><br>The primary function is to identify the SharePoint version, enabling conditional logic in macros or scripts. For instance, certain features or methods may behave differently across SharePoint versions, and knowing the version allows for adaptive code. If the workbook is not stored on SharePoint, the property typically returns 0.<\/p>\n\n\n\n<p><strong>Syntax in xlwings:<\/strong><br>The property is accessed through the <code>Application<\/code> object. In xlwings, after establishing a connection to Excel (usually via <code>app = xw.App()<\/code> or <code>xw.Book<\/code>), you can retrieve the value as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to the active Excel instance or create a new one\napp = xw.apps.active # or xw.App() for a new instance\nsharepoint_version = app.api.SharePointVersion<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Parameters:<\/strong> The <code>SharePointVersion<\/code> property does not take any parameters.<\/li>\n\n\n\n<li><strong>Return Value:<\/strong> It returns an integer representing the SharePoint version. Common values include:<\/li>\n\n\n\n<li><code>0<\/code>: The workbook is not stored on a SharePoint site, or SharePoint is not detected.<\/li>\n\n\n\n<li><code>14<\/code>: Corresponds to SharePoint 2010.<\/li>\n\n\n\n<li><code>15<\/code>: Corresponds to SharePoint 2013.<\/li>\n\n\n\n<li><code>16<\/code>: Corresponds to SharePoint 2016 or SharePoint Online (Office 365).<\/li>\n\n\n\n<li>Other integer values may represent different or future versions.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example Usage:<\/strong><br>Below is a practical xlwings code example that checks the SharePoint version and performs actions based on the result. This example assumes Excel is already running with a workbook open, possibly from a SharePoint location.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\ndef check_sharepoint_version():\n# Get the active Excel application\napp = xw.apps.active\n\n# Retrieve the SharePoint version\nversion = app.api.SharePointVersion\n\n# Display or use the version information\nif version == 0:\n    print(\"This workbook is not stored on SharePoint.\")\nelif version == 14:\n    print(\"SharePoint 2010 detected. Implement compatibility for this version.\")\n# Add version-specific code here, e.g., adjust data connection settings\nelif version == 15:\n    print(\"SharePoint 2013 detected. Features for this version are available.\")\nelif version == 16:\n    print(\"SharePoint 2016 or SharePoint Online detected. Use modern APIs.\")\nelse:\n    print(f\"Unknown SharePoint version: {version}. Check for updates.\")\n\n# You can also use the value in conditional logic for further automation\nif version >= 16:\n# Example: Enable newer SharePoint integration features\n    print(\"Proceeding with advanced SharePoint functionalities.\")\n    return version\n\n# Run the function\nif __name__ == \"__main__\":\n    sharepoint_ver = check_sharepoint_version()\n    print(f\"SharePoint Version Code: {sharepoint_ver}\")<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `SharePointVersion` property of the `Application` object in Excel&apos;s object model provides a read&#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-2014","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2014","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=2014"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2014\/revisions"}],"predecessor-version":[{"id":3074,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2014\/revisions\/3074"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}