Table of contents
Collapse the table of content
Expand the table of content

Shape.DeleteSection Method (Visio)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Deletes a ShapeSheet section.


expression . DeleteSection( Section )

expression A variable that represents a Shape object.


NameRequired/OptionalData TypeDescription
SectionRequiredIntegerThe index of the section to delete.

Return Value



When you delete a ShapeSheet section, all rows in the section are automatically deleted. If the specified section does not exist, nothing is deleted and no error is generated.

If a Geometry section is deleted, any subsequent Geometry sections shift up because they are indexed and no gaps can exist in an indexed range.

You can delete any section except the section represented by visSectionObject (although you can delete rows within that section).

Section index values are declared in the Visio type library in VisSectionIndices .


The following Microsoft Visual Basic for Applications (VBA) macro shows how to delete a ShapeSheet section.

Public Sub DeleteSection_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 of the rectangle. 
 vsoShape.AddSection visSectionScratch 

 'Delete the scratch section from the ShapeSheet. 
 vsoShape.DeleteSection visSectionScratch 

End Sub
© 2017 Microsoft