會將新的區段新增至 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 支援與意見反應。