AddRow Method [Visio 2003 SDK Documentation]

Adds a row to a ShapeSheet section at a specified position.

retVal = object**.AddRow** (Section, Row, RowTag)

retVal     Integer. The row number of the row that was added.

object     Required. An expression that returns a Shape object.

Section     Required Integer. The section in which to add the row.

Row     Required Integer. The position at which to add the row.

RowTag     Required Integer. The type of row to add.

Version added

2.0

Remarks

If the ShapeSheet section does not already exist, it is created with a blank row. New cells in new rows are initialized with default formulas, if applicable. Otherwise, a program must include statements to set the formulas for the new cells. If the new row cannot be added, an error is generated.

The Visio type library declares row constants prefixed with visRow in VisRowIndices.

Constants for rows in the Geometry, Connection Points, and Controls sections are prefixed with visTag and declared by the type library in VisRowTags. To see a list of these constants, see the RowType property.

The row constants declared by the Visio type library serve as base positions at which a section's rows begin. Add offsets to these constants to specify the first row and beyond, for example, visRowFirst+0, visRowFirst+1, and so on. To add rows at the end of a section, pass the constant visRowLast for the Row argument. The value returned is the actual row index.

The RowTag argument specifies the type of row to add. To generate a section's default row type, pass visTagDefault (0) as the RowTag argument. Explicit tags are useful when adding rows to Geometry, Connection Points, and Controls sections. See the RowType property for descriptions of valid row types for these sections. Passing an invalid row type generates an error.

If you try to add a row to a Character, Tabs, or Paragraph section, an error occurs.

The AddRow method cannot add named rows. To add named rows, use the AddNamedRow method.

If you add rows to a section that has nameable rows (for example, the Connection Points or Controls section), the Row argument is ignored. By default, named rows are named in the order added, for example, Row_1, Row_2, and so forth. Naming order is influenced, however, by any existing rows or previously deleted rows.

Example

The following example shows how to add a section to a ShapeSheet and how to add a row to the section at a specified position.

Public Sub AddRow_Example() 

    Dim vsoPage As Visio.Page
    Dim vsoShape As Visio.Shape 

    'Get the active page. 
     Set vsoPage = ActivePage

    'If there isn't an active page, set the Page object
    'to the first page of the active document.
    If vsoPage Is Nothing Then
        Set vsoPage = ActiveDocument.Pages(1) 
    End If 
 
    '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 

    'Add a row to the scratch section.
    vsoShape.AddRow visSectionScratch, visRowScratch, 0 

End Sub  

Applies to | Shape object

See Also | AddNamedRow method | AddRows method | RowName property | RowType property