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

Selection.Trim Method (Visio)

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

Trims selected shapes into smaller shapes.


expression . Trim

expression A variable that represents a Selection object.

Return Value



Calling the Trim method is equivalent to clicking Trim in the Microsoft Visio user interface (click Operations in the Shape Design group on theDeveloper tab).

The new shapes inherit the formatting of the first selected shape, have no text, and are the topmost shapes in their container—the n_th shape, _n_th - 1 shape, _n_th - 2 shape, and so forth in the Shapes collection of their containing shape, where _n = count. The original shapes are deleted and no shapes are selected when the operation is complete.

The Trim method is similar to the Fragment method but differs in the following ways:

  • Shapes produced by the Trim method coincide with the distinct paths of the selected shapes, taking overlap into account.

  • Shapes produced by the Fragment method coincide with the distinct regions of the selected shapes, also taking overlap into account.


This Microsoft Visual Basic for Applications (VBA) macro shows how to use the Trim method to trim selected shapes into smaller shapes along their intersections.

Public Sub Trim_Example() 

 Dim vsoShape1 As Visio.Shape 
 Dim vsoShape2 As Visio.Shape 
 Dim shapeCount As Integer 

 'Draw two shapes that intersect 
 Set vsoShape1 = ActivePage.DrawRectangle(1, 4, 4, 1) 
 Set vsoShape2 = ActivePage.DrawOval(2, 6, 3, 2) 

 'Deselect the oval and then select both of the new shapes on the page 

 'Create a selection object and assign the selected shapes to it 
 Dim vsoSelection As Visio.Selection 
 Set vsoSelection = ActiveWindow.Selection 

 'Trim the selected shapes 

 'Move one of the newly created shapes 
 shapeCount = ActivePage.Shapes.Count 

 Set vsoShape1 = ActivePage.Shapes(shapeCount - 2) 
 ActiveWindow.Select vsoShape1, visSelect 
 ActiveWindow.Selection.Move 2, 2 

End Sub
© 2018 Microsoft