{"id":2092,"date":"2026-05-29T15:19:23","date_gmt":"2026-05-29T07:19:23","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2092"},"modified":"2026-03-28T06:22:36","modified_gmt":"2026-03-28T06:22:36","slug":"how-to-use-applicationdisplayscrollbars-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationdisplayscrollbars-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.DisplayScrollBars in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>DisplayScrollBars<\/code> property of the <code>Application<\/code> object in Excel controls the visibility of scroll bars in workbook windows. This feature is particularly useful when creating custom dashboards or reports where you want to minimize interface distractions or ensure a clean layout. By manipulating this property, developers can programmatically show or hide both horizontal and vertical scroll bars across all open workbooks, enhancing the user experience in automated Excel applications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In xlwings, the <code>DisplayScrollBars<\/code> property is accessed through the <code>app<\/code> object, which represents the Excel application. The property is a boolean value that can be set to <code>True<\/code> to display scroll bars or <code>False<\/code> to hide them. The syntax is straightforward: <code>app.display_scroll_bars = value<\/code>, where <code>value<\/code> is either <code>True<\/code> or <code>False<\/code>. It&#8217;s important to note that this setting applies globally to the Excel instance, affecting all workbooks currently open. There are no additional parameters or arguments for this property, making it simple to implement.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, consider a scenario where you are generating a financial report and want to hide scroll bars to prevent users from accidentally scrolling away from the main data view. You can use the following xlwings code:<\/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\n\n# Hide the scroll bars\napp.display_scroll_bars = False\n\n# Perform other operations, such as writing data or formatting\n# ...\n\n# To show the scroll bars again, set it to True\napp.display_scroll_bars = True<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Another common use case is in a script that prepares multiple workbooks for presentation. You might want to ensure scroll bars are hidden consistently across all files. Here&#8217;s a more comprehensive example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Start Excel if not already running\napp = xw.App(visible=True)\n\n# Hide scroll bars for a cleaner look\napp.display_scroll_bars = False\n\n# Open or create workbooks and manipulate them as needed\nwb = app.books.add()\nsheet = wb.sheets&#91;0]\nsheet.range('A1').value = 'Sample Data'\n\n# After completing tasks, you can restore scroll bars if desired\napp.display_scroll_bars = True\n\n# Save and close\nwb.save('report.xlsx')\nwb.close()\napp.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `DisplayScrollBars` property of the `Application` object in Excel controls the visibility of scr&#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-2092","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2092","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=2092"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2092\/revisions"}],"predecessor-version":[{"id":3201,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2092\/revisions\/3201"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}