Share via


AddSection Method [Visio 2003 SDK Documentation]

Adds a new section to a ShapeSheet spreadsheet.

intRet = object**.AddSection** (section)

intRet     Integer. The index of the section that was added.

object     Required. An expression that returns a Shape object.

section     Required Integer. The type of section to add.

Version added

2.0

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 Custom Properties. 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 InsertSection 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.

The Visio type library declares the constants for sections in VisSectionIndices.

Example

The following macro shows how to add a new 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  

Applies to | Shape object

See Also | AddRow method | CellsSRC property | GeometryCount property | SectionExists property