{"id":2122,"date":"2026-06-13T16:16:14","date_gmt":"2026-06-13T08:16:14","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2122"},"modified":"2026-03-28T07:18:26","modified_gmt":"2026-03-28T07:18:26","slug":"how-to-use-applicationheight-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationheight-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.Height in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <strong>Height<\/strong> property of the <strong>Application<\/strong> object in Excel refers to the height, in points, of the main application window. This property is part of the window management capabilities, allowing developers to programmatically control the size and position of the Excel window. In xlwings, this property is accessible through the <code>api<\/code> property, which provides direct access to the underlying Excel object model. By manipulating the <strong>Height<\/strong> property, you can adjust the window&#8217;s vertical dimension to fit specific user interface requirements or to optimize the display for different screen resolutions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax in xlwings:<\/strong><br><code>app.api.Height<\/code><br>Here, <code>app<\/code> represents the xlwings App object, which corresponds to the Excel application instance. The <strong>Height<\/strong> property is a read\/write property of type <strong>Single<\/strong> (a floating-point number). When setting the height, the value is specified in points, where one point equals 1\/72 of an inch. The minimum and maximum allowable values depend on the screen resolution and system settings, but typically, the height can range from a small window size to the full screen height. To retrieve the current height, you can read this property; to change it, assign a new numeric value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example Usage:<\/strong><br>Below are practical xlwings API code examples that demonstrate how to get and set the <strong>Height<\/strong> property of the Excel application window.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Getting the Current Height:<\/strong><br>This example retrieves the current height of the Excel window and prints it to the console. It is useful for logging or conditional resizing based on the existing window size.<\/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\ncurrent_height = app.api.Height # Read the Height property\nprint(f\"The current Excel window height is {current_height} points.\")<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Setting a Specific Height:<\/strong><br>Here, the height of the Excel window is set to 600 points. This can be used to standardize the window size across different user sessions or to create a tailored viewing area.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.apps.active\napp.api.Height = 600 # Set the Height property to 600 points\nprint(\"Excel window height has been set to 600 points.\")<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Dynamic Resizing Based on Screen Resolution:<\/strong><br>This advanced example calculates a percentage of the screen&#8217;s working area height (using the <code>pyautogui<\/code> library for screen info) and sets the Excel window accordingly. It ensures the window adapts to different monitor setups.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\nimport pyautogui\napp = xw.apps.active\nscreen_width, screen_height = pyautogui.size() # Get screen dimensions\nnew_height = screen_height * 0.75 # Set to 75% of screen height\napp.api.Height = new_height\nprint(f\"Excel window height adjusted to {new_height:.0f} points (75% of screen height).\")<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Restoring Window to a Default Size:<\/strong><br>In this scenario, the height is reset to a default value (e.g., 500 points) as part of a cleanup or initialization routine, ensuring consistency in the user interface.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.apps.active\ndefault_height = 500\napp.api.Height = default_height\nprint(f\"Excel window height restored to {default_height} points.\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The **Height** property of the **Application** object in Excel refers to the height, in points, of t&#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-2122","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2122","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=2122"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2122\/revisions"}],"predecessor-version":[{"id":3244,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2122\/revisions\/3244"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}