Shape.DeleteSection method (Visio)
Deletes a ShapeSheet section.
expression A variable that represents a Shape object.
|Section||Required||Integer||The index of the section to delete.|
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
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.