ContainerProperties.AddMember Method (Visio)
Adds a shape or a set of shapes to the container.
expression .AddMember(pObjectToAdd, addOptions)
expression A variable that represents a ContainerProperties object.
The addOptions parameter value must be one of the following VisMemberAddOptions constants.
Defer to the setting of the ContainerProperties.ResizeAsNeeded property.
Expand the container to fit the incoming shapes.
Do 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.