How to: Programmatically Add Shapes to a Visio Document

 

You can add shapes to a Microsoft Office Visio document by retrieving the masters from a stencil and dropping the shapes on the active page.

For more information, see the VBA reference documentation for the Microsoft.Office.Interop.Visio.Documents.Add method, Microsoft.Office.Interop.Visio.Application.ActivePage property, and Microsoft.Office.Interop.Visio.Page.Drop method.

To add shapes to a Visio document

  • With a document active, retrieve the masters from the Documents.Masters collection and drop the shapes on the active document. You can retrieve a master by using the index or master name.

    The following code example creates a blank Visio document, and then opens it with the Basic Shapes stencil docked. The code then retrieves several shapes and drops them on the active page.

    No code example is currently available or this language may not be supported.
Show: