How to use Application.DisplayNoteIndicator in the xlwings API way

The DisplayNoteIndicator property of the Application object in Excel is a setting that controls whether comment indicators (small red triangles) are displayed in cells that contain comments. This property is particularly useful for managing the visual clutter in a worksheet, especially when dealing with a large number of comments. By toggling this setting, users can choose to show or hide these indicators, which can improve readability and focus on the data itself. In xlwings, this property is accessed through the Application object, allowing for programmatic control over the display of comment indicators across the entire Excel application instance.

Syntax in xlwings:

app.display_note_indicator

This property is a read/write Boolean value. When set to True, comment indicators are displayed in cells containing comments. When set to False, these indicators are hidden. Note that hiding the indicators does not delete the comments themselves; they remain accessible via other means, such as hovering over the cell (if enabled) or through the Review tab in the Excel interface.

Parameters:
The property does not accept parameters directly. It is a simple Boolean attribute that can be set or retrieved.

Example Usage:

Here is a practical example demonstrating how to use the DisplayNoteIndicator property in xlwings. This script connects to an existing Excel instance, toggles the display of comment indicators, and prints the current state.

import xlwings as xw

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

# Get the current state of DisplayNoteIndicator
current_setting = app.display_note_indicator
print(f"Current DisplayNoteIndicator setting: {current_setting}")

# Toggle the setting: if it's True, set to False, and vice versa
app.display_note_indicator = not current_setting
print(f"DisplayNoteIndicator toggled to: {app.display_note_indicator}")

# Example: Hide comment indicators
app.display_note_indicator = False
print("Comment indicators are now hidden.")

# Example: Show comment indicators
app.display_note_indicator = True
print("Comment indicators are now visible.")

May 28, 2026 (0)


Leave a Reply

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