
In Microsoft Visio, comments are annotations or notes that can be added to shapes, diagrams, or specific areas within a diagram. These comments provide additional information, explanations, or instructions about the content of the diagram. Comments are a way to communicate context, details, or feedback related to the elements present in the Visio diagram. Visio allows users to attach comments to shapes, connectors, or the background of the diagram. In this article, we will learn how to add comments to Visio diagrams in Python. We will also learn how to edit existing comments in VSD or VSDX files programmatically using Python.
This article covers the following topics:
- Python API to Add Comments to a Visio Diagram
- Add Comments to Visio Diagram in Python
- Add Comments to Shape in Visio Diagram
- Edit Comments in Visio Diagram
- Free Learning Resources
Python API to Add Comments to Visio Diagram
For adding comments to Visio diagram, we will use Aspose.Diagram for Python. It enables developers to work with Microsoft Visio files programmatically in Python applications. It allows the creation of new diagrams, modification of existing ones, extraction of information, conversion to different formats, and more. Aspose.Diagram for Python simplifies development when working with Visio files and provides a high‑level API for interacting with these files using Python.
Please download the package or install the API from PyPI using the following pip command in the console:
pip install aspose-diagram-python
Add Comments to Visio Diagram in Python
We can easily add comments to a Visio diagram by following the steps below:
- Load the Visio diagram using the Diagram class.
- Get a specific page by index from the pages collection.
- Insert a comment using the add_comment() method.
- Save the Visio diagram using the save() method. Provide the output VSDX file path and
SaveFileFormatas arguments.
The following code sample shows how to add a page‑level comment to a Visio diagram in Python.

Add Comments to Visio Diagram in Python.
Add Comments to Shape in Visio Diagram using Python
Similarly, we can add comments to a specific shape of a Visio diagram by following these steps:
- Load the Visio diagram using the Diagram class.
- Get a specific page by index from the pages collection.
- Get a specific shape by ID from the page’s shapes collection.
- Insert a comment using the add_comment() method. Pass the shape object and the comment text as arguments.
- Save the Visio diagram using the save() method. Provide the output VSDX file path and
SaveFileFormatas arguments.
The following code sample shows how to add a comment to a shape in a Visio diagram using Python.

Add Comments to a Shape in Visio Diagram using Python.
Edit Comments in Visio Diagram using Python
We can also edit any comment in a Visio diagram by following these steps:
- Load the Visio diagram using the Diagram class.
- Get a specific page by index from the pages collection.
- Iterate through the collection of annotations.
- Read the comment.value property and update it.
- Save the Visio diagram using the save() method. Provide the output VSDX file path and
SaveFileFormatas arguments.
The following code sample shows how to edit a comment in a Visio diagram using Python.

Edit Comments in Visio Diagram using Python.
Get a Free API License
Get a free temporary license and experience the library’s capabilities at no cost. Utilizing a free temporary license enables you to explore the features of the library without encountering any restrictions.
Add Comments to Visio Diagram – Learning Resources
Explore other features of the library and learn how to generate, convert, and manipulate Visio diagrams without using Microsoft Visio using the following resources:
Conclusion
In this blog post, we learned how to add comments to Visio diagrams in Python. By leveraging Aspose.Diagram for Python, developers can automate the process of annotating Visio diagrams programmatically using Python. For any questions, please contact us on our free support forum.