Visio) (Cell.Precedents 屬性

傳回另一個儲存格公式所依存的 ShapeSheet 儲存格陣列。 唯讀。

語法

運算式。前導參照

運算式 代表 Cell 物件的變數。

傳回值

儲存格 ()

註解

Precedents 屬性會傳回一個儲存格陣列,當父 Cell 物件的公式或值變更時,會重新計算其值。

範例

下列Microsoft Visual Basic for Applications (VBA) 巨集 示範如何使用 Precedents 屬性顯示圖形的 “Scratch.X1” 儲存格所依存的儲存格清單。 巨集會在使用中頁面上繪製一個矩形,將 Scratch 區段新增至矩形的 ShapeSheet,然後在該區段的儲存格中輸入公式,用於將矩形的邊向內彎曲,方法是將每個矩形的邊變更為弧形。因為用來彎曲矩形邊的公式取決於矩形的寬度和高度,所以包含公式的儲存格 Scratch.X1 會取決於矩形圖案的 Width 和 Height 儲存格,因此會讓這些儲存格成為前置儲存格。

Public Sub Precedents_Example() 
 
 Dim acellPrecedentCells() As Visio.Cell 
 Dim vsoCell As Visio.Cell 
 Dim vsoShape As Visio.Shape 
 Dim strBowCell As String 
 Dim strBowFormula As String 
 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" 
 
 'Draw a rectangle on the active page 
 Set vsoShape = ActivePage.DrawRectangle(1, 5, 5, 1) 
 
 'Add a scratch section and then 
 vsoShape.AddSection visSectionScratch 
 
 'Add a row to the scratch section 
 vsoShape.AddRow visSectionScratch, visRowScratch, 0 
 
 'Place the value of strBowFormula into Scratch.X1 
 'Set the Cell object to the Scratch.X1 and set formula 
 Set vsoCell = vsoShape.Cells(strBowCell) 
 
 'Set up the offset for the arc 
 vsoCell.Formula = strBowFormula 
 
 'Bow in or curve the original rectangle's lines by changing 
 'each row to an arc 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 
 
 'Get the array of precedent cells 
 acellPrecedentCells = vsoShape.Cells("Scratch.X1").Precedents 
 
 'List the cell names and their associated formula 
 For intCounter = LBound(acellPrecedentCells) To UBound(acellPrecedentCells) 
 Set vsoCell = acellPrecedentCells(intCounter) 
 Debug.Print vsoCell.Name & " has this formula: " & vsoCell.Formula 
 Next 
 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。