會傳回 ShapeSheet 區段中的列數。 唯讀。
語法
expression。 RowCount( _Section_ )
表達 代表 Shape 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| Section | 必要 | 整數 | 要計算列數的區段。 |
傳回值
整數
註解
Section 引數必須是區段常數。 如需區段常數的清單,請參閱 AddSection 方法。
請將 RowCount 屬性主要用於包含變動列數的區段,例如 [幾何] 和 [連接點] 區段。 對於擁有固定列數的區段,RowCount 屬性會傳回區段中的列數,此區段中至少有一個儲存格的值是圖形本身所有 (與儲存格全都是從主圖形或樣式繼承而來的列相反)。 從主圖形或樣式繼承通常是較好的做法,因為 Microsoft Office Visio 不需要儲存大量資訊。 在 ShapeSheet 視窗中,具有本機值的儲存格會以藍色顯示,具有繼承值的儲存格則會以黑色顯示。 使用 IsInherited 屬性來判斷儲存格是否繼承。
範例
下列的 Microsoft Visual Basic for Applications (VBA) 巨集會示範如何使用 RowCount 屬性來尋找要重覆的 ShapeSheet 列數。
若要執行這個巨集,請開啟空白的繪圖以及 Computers and Monitors (US Units) 樣板,然後插入包含標籤、文字方塊和清單方塊的使用者表單。 將清單方塊的寬度設定為 150。
注意事項
只有 Microsoft Office Visio Professional 才有提供 Computers and Monitors (US Units) 樣板。
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 支援與意見反應。