ContainerProperties.AddMember method (Visio)
Adds a shape or a set of shapes to the container.
Syntax
expression.AddMember (pObjectToAdd, addOptions)
expression A variable that represents a ContainerProperties object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
pObjectToAdd | Required | UNKNOWN | The shape or shapes to add to the container. Can be of type Shape or Selection. |
addOptions | Required | VisMemberAddOptions | Determines whether the container should expand to fully contain the added shapes. Must be one of the VisMemberAddOptions constants. |
Return value
Nothing
Remarks
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.
Example
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.