Table of contents
Collapse the table of content
Expand the table of content

ContainerProperties.AddMember Method (Visio)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Adds a shape or a set of shapes to the container.


expression . AddMember( pObjectToAdd , addOptions )

expression A variable that represents a ContainerProperties object.


NameRequired/OptionalData TypeDescription
pObjectToAddRequired[UNKNOWN]The shape or shapes to add to the container. Can be of type Shape or Selection .
addOptionsRequiredVisMemberAddOptionsDetermines whether the container should expand to fully contain the added shapes.

Return Value



The addOptions parameter value must be one of the following VisMemberAddOptions constants.

visMemberAddUseResizeSetting0Defer to the setting of the ContainerProperties.ResizeAsNeeded property.
visMemberAddExpandContainer1Expand the container to fit the incoming shapes.
visMemberAddDoNotExpand2Do not expand the container to fit the incoming shapes.

Passing visMemberAddUseResizeSetting or visMemberAddDoNotExpand for addOptions can create a situation in which a shape is a container member but not physically within the container. In such a case, the shape can lose its container membership on subsequent moves or resizing of either the container or the member.

If the container is a list, AddMember adds the specified object to the list container, but not to the list itself. In other words, the shape is contained by the list but is not actually in the list. This is common for shapes in containers that are themselves in a list.

If the ContainerProperties.LockMembership property is True , Microsoft Visio returns a Disabled error.

If the pObjectToAdd parameter does not contain top-level shapes on the page, Visio returns an Invalid Parameter error.

Visio also returns an Invalid Parameter error if you attempt to use the AddMember method to add the container shape itself or subshapes of the container to the container.

Visio returns an Invalid Target error if pObjectToAdd does not match the category requirements of the list or the container. Shapes can be assigned categories, and containers can have required and excluded categories.

Categories are user-defined strings that you can use to categorize shapes and, thereby, to restrict membership in a container. You can define categories in the User.msvShapeCategories cell in the ShapeSheet for a shape. You can define multiple categories for a shape by separating them with semicolons.


The following Visual Basic for Applications (VBA) example shows how to use the AddMember method to add a new member (vsoShape) to an existing container (vsoContainerShape) on a page. The code assumes that vsoShape already overlaps vsoContainerShape.

vsoContainerShape.ContainerProperties.AddMember vsoShape, visMemberAddExpandContainer
© 2017 Microsoft