Shape.AddSection method (Visio)

Adds a new section to a ShapeSheet spreadsheet.

Syntax

expression. AddSection( _Section_ )

expression A variable that represents a Shape object.

Parameters

Name Required/Optional Data type Description
Section Required Integer The type of section to add.

Return value

Integer

Remarks

The AddSection method is frequently used to add one or more Geometry sections to a shape. You can also use AddSection to add other sections to a shape such as Scratch, Controls, Connection Points, Actions, User-Defined Cells and ShapeData. The AddSection method returns the logical index of the added section.

The sections that you can add to a shape correspond to the choices shown by the Insert Section dialog box when the shape is displayed in a ShapeSheet window.

If you try to add a non-Geometry section to a shape that already has that section, the AddSection method raises an exception. Use the SectionExists property to determine if a shape already has a section with a given logical index.

A new section has no rows. Use the AddRow method to add rows to the new section.

The GeometryCount property returns the number of Geometry sections included in a shape. Use the following code to add a Geometry section to a shape:

Shape.AddSection(visSectionFirstComponent + i) 

where 0 <= i < visSectionLastComponent - visSectionFirstComponent.

  • When 0 <= i < Shape.GeometryCount, the new section precedes the present i'th Geometry section.

  • When Shape.GeometryCount <= i < visSectionLastComponent - visSectionFirstComponent, the new section is the last section.

Example

The following macro shows how to add a Scratch section to the ShapeSheet of a rectangle. Before running this macro, make sure a drawing page is active in the Visio window.

 
Public Sub AddSection_Example() 
 
 Dim vsoPage As Visio.Page 
 Dim vsoShape As Visio.Shape 
 
 'Get the active page. 
 Set vsoPage = ActivePage 
 
 'Draw a rectangle on the active page. 
 Set vsoShape = vsoPage.DrawRectangle(1, 5, 5, 1) 
 
 'Add a scratch section to the ShapeSheet. 
 vsoShape.AddSection visSectionScratch 
 
End Sub

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.