Shape.RowCount 属性 (Visio)

返回“ShapeSheet”内容中的行数。 此为只读属性。

语法

expressionRowCount( _Section_ )

表达 一个代表 Shape 对象的变量。

参数

名称 必需/可选 数据类型 说明
Section 必需 Integer 要对其中的行计数的内容。

返回值

整数

备注

Section 参数必须是内容常量。 有关内容常量的列表,请参阅 AddSection 方法。

RowCount 属性主要用于包含可变行数的内容,例如“Geometry”和“Connection Points”内容。 对于包含固定行数的内容,RowCount 属性返回拥有至少一个其值对于形状而言是本地值的单元格的内容中的行(而不是其单元格全部继承自主控形状或样式的行)的数目。 继承自主控形状或样式通常更好,因为 Microsoft Office Visio 不需要存储同样多的信息。 在 ShapeSheet 窗口中,具有本地值的单元格显示为蓝色,而具有继承值的单元格显示为黑色。 使用 IsInherited 属性确定单元格是否继承。

示例

以下 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用 RowCount 属性来查找要遍历的 ShapeSheet 行的数目。

要运行此宏,请打开一个空白绘图和“计算机和显示器(美制单位)”模具,然后插入一个包含标签、文本框和列表框的用户窗体。 将列表框的宽度设置为 150。

注意

“计算机和显示器(美制单位)”模具仅在 Microsoft Office Visio Professional 中可用。

 
Public Sub RowCount_Example() 
 
 Dim vsoStencil As Visio.Document 
 Dim vsoMaster As Visio.Master 
 Dim vsoPages As Visio.Pages 
 Dim vsoPage As Visio.Page 
 Dim vsoShape As Visio.Shape 
 Dim vsoCell As Visio.Cell 
 Dim intRows As Integer 
 Dim intCounter As Integer 
 
 'Get the Pages collection for the document. 
 'ThisDocument refers to the current document. 
 Set vsoPages = ThisDocument.Pages 
 
 'Get a reference to the first page of the Pages collection. 
 Set vsoPage = vsoPages(1) 
 
 'Get the Document object for the stencil. 
 Set vsoStencil = Documents("COMPS_U.VSS") 
 
 'Get the Master object for the desktop PC shape. 
 Set vsoMaster = vsoStencil.Masters("PC") 
 
 'Drop the shape in the approximate middle of the page. 
 'Coordinates passed to the Drop method are always in inches. 
 'The Drop method returns a reference to the new shape object. 
 Set vsoShape = vsoPage.Drop(vsoMaster, 4.25, 5.5) 
 
 'This example shows two methods of extracting custom 
 'properties. The first method retrieves the value of a custom 
 'property by name. 
 'Note that Prop.Manufacturer implies Prop.Manufacturer.Value. 
 Set vsoCell = vsoShape.Cells("Prop.Manufacturer") 
 
 'Get the cell value as a string 
 'and put it into the text box on the form. 
 UserForm1.TextBox1.Text = vsoCell.ResultStr(Visio.visNone) 
 
 'Set the caption of the label. 
 UserForm1.Label1.Caption = "Prop.Manufacturer" 
 
 'The second method of accessing custom properties uses 
 'section, row, cell. This method is best when you want 
 'to iterate through all the properties. 
 intRows = vsoShape.RowCount(Visio.visSectionProp) 
 
 'Make sure the list box is cleared. 
 UserForm1.ListBox1.Clear 
 
 'Loop through all the rows and add the value of Prop.Manufacturer 
 'to the list box. Rows are numbered starting with 0. 
 For intCounter = 0 To intRows - 1 
 Set vsoCell = vsoShape.CellsSRC(Visio.visSectionProp, intCounter, visCustPropsValue) 
 UserForm1.ListBox1.AddItem vsoCell.LocalName & vbTab & _ 
 vsoCell.ResultStr(Visio.visNone) 
 Next intCounter 
 
 'Display the user form. 
 UserForm1.Show 
 
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。