Visio) (Shape.AddSection 方法

會將新的區段新增至 ShapeSheet 試算表。

語法

expression。 AddSection( _Section_ )

expression 一個用於表示 Shape 物件的變數。

參數

名稱 必要/選用 資料類型 描述
Section 必要 整數 要新增之區段的類型

傳回值

整數

註解

AddSection 方法頻繁地用於將一個或多個 Geometry 區段新增至圖形。 您也可以使用 AddSection 新增其他區段 (例如,Scratch、Controls、Connection Points、Actions、User-Defined Cells 及 ShapeData) 至圖形。 AddSection 方法會傳回新增之區段的邏輯索引。

您可以新增至圖形的區段,對應至圖形在 ShapeSheet 視窗中顯示時,[ 插入區段 ] 對話方塊所顯示的選擇。

如果您嘗試將非 Geometry 區段新增至圖形,且圖形已有該區段,AddSection 方法會發生例外狀況。 使用 SectionExists 屬性來判斷圖形是否已有具指定邏輯索引的區段。

新的區段沒有列。 使用 AddRow 方法,將列新增至新的區段。

GeometryCount 屬性傳回圖形中包含的 Geometry 區段數。 使用下列代碼,將 Geometry 區段新增至圖形:

Shape.AddSection(visSectionFirstComponent + i) 

其中 0 <= i <visSectionLastComponent - visSectionFirstComponent。

  • 當 0 <= i <Shape.GeometryCount 時,新區段會在目前的第 i 個幾何區段之前。

  • 當 Shape.GeometryCount<= i <visSectionLastComponent - visSectionFirstComponent 時,新的剖面就是最後一個剖面。

範例

下列巨集會顯示如何新增 Scratch 區段至矩形的 ShapeSheet。 執行此巨集之前,請確定 Visio 視窗的繪圖頁面是在作用中。

 
Public Sub AddSection_Example() 
 
 Dim vsoPage As Visio.Page 
 Dim vsoShape As Visio.Shape 
 
 'Get the active page. 
 Set vsoPage = ActivePage 
 
 '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 
 
End Sub

支援和意見反應

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