Share via


Visio (的 Selection.Trim 方法)

會將選取的圖形修剪為較小的圖形。

語法

expressionTrim

表達 代表 Selection 物件的變數。

傳回值

註解

呼叫 Trim 方法等同於按一下 Microsoft Visio 使用者介面中的 [修剪] (按一下 [開發人員] 索引標籤上 [圖形設計] 群組中的 [作業])。

新圖案會繼承第一個選取圖案的格式、沒有文字,而且是其容器中最上層的圖案—_n_th圖案、_n_th - 1 個圖案、_n_th - 2 個圖案,依此類推在其包含圖案的 Shapes 集合中,其中 n = count。 當作業完成時,會刪除原始圖形,而且不會選取任何圖形。

Trim 方法類似於 Fragment 方法,但是有下列差異:

  • Trim 方法所產生的圖形會與選取圖形的個別路徑一致,會將重疊納入考慮。

  • Fragment 方法所產生的圖形會與選取圖形的個別區域一致,也會將重疊納入考量。

範例

這個 Microsoft Visual Basic for Applications (VBA) 巨集會顯示如何使用 Trim 方法沿著圖形的交叉點將選取的圖形修剪為較小的圖形。

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 
 ActiveWindow.DeselectAll 
 ActiveWindow.SelectAll 
 
 'Create a selection object and assign the selected shapes to it 
 Dim vsoSelection As Visio.Selection 
 Set vsoSelection = ActiveWindow.Selection 
 
 'Trim the selected shapes 
 vsoSelection.Trim 
 
 'Move one of the newly created shapes 
 ActiveWindow.DeselectAll 
 shapeCount = ActivePage.Shapes.Count 
 
 Set vsoShape1 = ActivePage.Shapes(shapeCount - 2) 
 ActiveWindow.Select vsoShape1, visSelect 
 ActiveWindow.Selection.Move 2, 2 
 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應