How to use Application.DisplayDocumentInformationPanel in the xlwings API way

The Application.DisplayDocumentInformationPanel property in Excel’s object model controls the visibility of the Document Information Panel (DIP) for the active workbook. This panel, when visible, typically displays metadata properties of the document based on its associated content type or custom XML parts. In xlwings, this functionality is exposed through the api property, which provides direct access to the underlying Excel VBA object model. Using this property, you can programmatically check whether the panel is currently displayed or change its visibility state, which can be useful in automation scripts that manage the user interface or document properties workflow.

Functionality
The primary function is to get or set a Boolean value indicating if the Document Information Panel is visible. This can help in UI automation, ensuring a consistent interface state, or in processes where metadata entry or review is required.

Syntax in xlwings

# To get the current visibility state
visible = xw.apps[0].api.DisplayDocumentInformationPanel

# To set the visibility state (True to show, False to hide)
xw.apps[0].api.DisplayDocumentInformationPanel = True
  • Property Type: Read/write Boolean.
  • Return Value: When getting, it returns True if the panel is visible; otherwise, False.
  • Parameter for Setting: A Boolean value (True or False). Setting it to True displays the panel; False hides it. Note that the effect might depend on the workbook’s properties and Excel’s configuration.

Code Examples
Here are practical xlwings API examples demonstrating its usage:

  1. Check and Report Current Visibility
import xlwings as xw

# Connect to the active Excel instance
app = xw.apps.active

# Get the current state of the Document Information Panel
is_visible = app.api.DisplayDocumentInformationPanel

# Output the result
if is_visible:
    print("The Document Information Panel is currently visible.")
else:
    print("The Document Information Panel is currently hidden.")
  1. Toggle the Panel Visibility
import xlwings as xw

app = xw.apps.active

# Toggle the visibility: if visible, hide it; if hidden, show it
current_state = app.api.DisplayDocumentInformationPanel
app.api.DisplayDocumentInformationPanel = not current_state

print(f"Toggled the panel. New state: {app.api.DisplayDocumentInformationPanel}")
  1. Ensure the Panel is Hidden for a Clean UI
import xlwings as xw

# Start or connect to Excel
app = xw.App(visible=True) # Make Excel visible
app.books.add() # Open a new workbook

# Force the Document Information Panel to be hidden
app.api.DisplayDocumentInformationPanel = False

print("Document Information Panel has been hidden.")

May 24, 2026 (0)


Leave a Reply

Your email address will not be published. Required fields are marked *