Style.CellsSRC 屬性 (Visio)
會傳回 Cell 物件,此物件代表根據區段、列和資料欄索引所識別的 ShapeSheet 儲存格。 唯讀。
語法
expression。 CellsSRC
( _Section_
, _Row_
, _Column_
)
表達 代表 Style 物件的變數。
參數
名稱 | 必要/選用 | 資料類型 | 描述 |
---|---|---|---|
Section | 必要 | 整數 | 儲存格的區段索引。 |
Row | 必要 | 整數 | 儲存格的列索引。 |
欄 | 必要 | 整數 | 儲存格的資料欄索引。 |
傳回值
儲存格
註解
若要藉由圖形的區段、列和資料欄索引存取任何圖形,可以使用 CellsSRC 屬性。 Visio 類型程式庫會分別將區段、資料列和資料行索引的常數宣告為 VisSectionIndices、 VisRowIndices和 VisCellIndices的成員。
如果區段、資料列和資料行的索引值無法識別實際的儲存格,則 CellsSRC 屬性可能會引發例外狀況,視區段而定。 不過,即使不會觸發例外,在傳回的物件上所觸發的後續方法也會失敗。 您可以使用 CellsSRCExists 屬性來判斷具有特定索引值的儲存格是否存在。
CellsSRC 屬性通常會用來重覆區段或列中的儲存格。 若要擷取單一的儲存格,可以使用 Cells 屬性並指定儲存格名稱。 例如:
Set vsoCell = Cells("PinX")
範例
下列 Microsoft Visual Basic for Applications (VBA) 宏會示範如何使用 CellsSRC 屬性,依其區段、資料列和資料行索引來設定特定的 ShapeSheet 儲存格。 它會在頁面上繪製矩形,然後將圖形的線條變更為弧線來彎曲矩形的線條。 然後宏會在第一個矩形的斜線內繪製內部矩形。
Public Sub CellsSRC_Example()
Dim vsoPage As Visio.Page
Dim vsoShape As Visio.Shape
Dim vsoCell As Visio.Cell
Dim strBowCell As String
Dim strBowFormula As String
Dim intIndex As Integer
Dim intCounter As Integer
'Set the value of the strBowCell string.
strBowCell = "Scratch.X1"
'Set the value of the strBowFormula string.
strBowFormula = "=Min(Width, Height) / 5"
Set vsoPage = ActivePage
'If there isn't an active page, set vsoPage
'to the first page of the active document.
If vsoPage Is Nothing Then
Set vsoPage = ActiveDocument.Pages(1)
End If
'Draw a rectangle on the active page.
Set vsoShape = vsoPage.DrawRectangle(1, 5, 5, 1)
'Add a scratch section to the shape's ShapeSheet
vsoShape.AddSection visSectionScratch
'Add a row to the scratch section.
vsoShape.AddRow visSectionScratch, visRowScratch, 0
'Set vsoCell to the Scratch.X1 cell and set its formula.
Set vsoCell = vsoShape.Cells(strBowCell)
vsoCell.Formula = strBowFormula
'Bow in or curve the rectangle's lines by changing
'each row type from LineTo to ArcTo and entering the bow value.
For intCounter = 1 To 4
vsoShape.RowType(visSectionFirstComponent, visRowVertex + intCounter) = visTagArcTo
Set vsoCell = vsoShape.CellsSRC(visSectionFirstComponent, visRowVertex + intCounter, 2)
vsoCell.Formula = "-" & strBowCell
Next intCounter
'Create an inner rectangle.
'Set the section index for the inner rectangle's Geometry section.
intIndex = visSectionFirstComponent + 1
'Add an inner rectangle Geometry section.
vsoShape.AddSection intIndex
'Add the first 2 rows to the section.
vsoShape.AddRow intIndex, visRowComponent, visTagComponent
vsoShape.AddRow intIndex, visRowVertex, visTagMoveTo
'Add 4 LineTo rows to the section
For intCounter = 1 To 4
vsoShape.AddRow intIndex, visRowLast, visTagLineTo
Next intCounter
'Set the inner rectangle start point cell formulas.
Set vsoCell = vsoShape.CellsSRC(intIndex, 1, 0)
vsoCell.Formula = "Width * 0 + " & strBowCell
Set vsoCell = vsoShape.CellsSRC(intIndex, 1, 1)
vsoCell.Formula = "Height * 0 + " & strBowCell
'Draw the inner rectangle bottom line.
Set vsoCell = vsoShape.CellsSRC(intIndex, 2, 0)
vsoCell.Formula = "Width * 1 - " & strBowCell
Set vsoCell = vsoShape.CellsSRC(intIndex, 2, 1)
vsoCell.Formula = "Height * 0 + " & strBowCell
'Draw the inner rectangle right side line.
Set vsoCell = vsoShape.CellsSRC(intIndex, 3, 0)
vsoCell.Formula = "Width * 1 - " & strBowCell
Set vsoCell = vsoShape.CellsSRC(intIndex, 3, 1)
vsoCell.Formula = "Height * 1 - " & strBowCell
'Draw the inner rectangle top line.
Set vsoCell = vsoShape.CellsSRC(intIndex, 4, 0)
vsoCell.Formula = "Width * 0 + " & strBowCell
Set vsoCell = vsoShape.CellsSRC(intIndex, 4, 1)
vsoCell.Formula = "Height * 1 - " & strBowCell
'Draw the inner rectangle left side line.
Set vsoCell = vsoShape.CellsSRC(intIndex, 5, 0)
vsoCell.Formula = "Geometry2.X1"
Set vsoCell = vsoShape.CellsSRC(intIndex, 5, 1)
vsoCell.Formula = "Geometry2.Y1"
End Sub
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。