Table of contents
TOC
折叠目录
展开目录

Shape.AddSection 方法 (Visio)Shape.AddSection Method (Visio)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

向 ShapeSheet 电子表格中添加新内容。Adds a new section to a ShapeSheet spreadsheet.

语法Syntax

表达式AddSection部分expression . AddSection( Section )

表达式_一个表示一个Shape对象的变量。_expression A variable that represents a Shape object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data Type说明Description
SectionSection必需RequiredIntegerInteger要添加的内容的类型。The type of section to add.

返回值Return Value

IntegerInteger

注解Remarks

AddSection方法经常用来向形状中添加一个或多个几何内容。此外可以使用AddSection来如划痕、 控件、 连接点、 操作、 用户定义的单元格和 ShapeData 形状中添加其他节。AddSection方法返回添加的部分的逻辑索引。The AddSection method is frequently used to add one or more Geometry sections to a shape. You can also use AddSection to add other sections to a shape such as Scratch, Controls, Connection Points, Actions, User-Defined Cells and ShapeData. The AddSection method returns the logical index of the added section.

您可以向形状中添加的部分对应于形状 ShapeSheet 窗口中显示时,插入内容对话框中所显示的选项。The sections that you can add to a shape correspond to the choices shown by the Insert Section dialog box when the shape is displayed in a ShapeSheet window.

如果您尝试将非几何内容添加到已包含该部分的形状, AddSection方法将引发异常。使用SectionExists属性以确定是否形状已具有给定的逻辑索引一节。If you try to add a non-Geometry section to a shape that already has that section, the AddSection method raises an exception. Use the SectionExists property to determine if a shape already has a section with a given logical index.

新的一节中没有任何行。使用AddRow方法将行添加到新的分区。A new section has no rows. Use the AddRow method to add rows to the new section.

GeometryCount属性返回几何形状中所含的部分的数。使用下面的代码添加到形状的几何内容:The GeometryCount property returns the number of Geometry sections included in a shape. Use the following code to add a Geometry section to a shape:

Shape.AddSection(visSectionFirstComponent + i) 

其中 0 < = i < visSectionLastComponent - visSectionFirstComponentwhere 0 <= i < visSectionLastComponent - visSectionFirstComponent .

  • 当 0 < = i < Shape.GeometryCount ,新节之前存在第 i 个几何内容。When 0 <= i < Shape.GeometryCount , the new section precedes the present i'th Geometry section.

  • Shape.GeometryCount < = i < visSectionLastComponent - visSectionFirstComponent ,新的部分是最后一节。When Shape.GeometryCount <= i < visSectionLastComponent - visSectionFirstComponent , the new section is the last section.

示例Example

下面的宏说明如何向矩形的 ShapeSheet 中添加“Scratch”内容。运行此宏之前,请确保绘图页在 Visio 窗口中处于活动状态。The following macro shows how to add a Scratch section to the ShapeSheet of a rectangle. Before running this macro, make sure a drawing page is active in the Visio window.


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
© 2018 Microsoft