Compartilhar via


Propriedade Cell.Precedents (Visio)

Devolve uma matriz de células shapeSheet das quais a fórmula de outra célula depende. Somente leitura.

Sintaxe

expressão. Precedentes

expressão Uma variável que representa um objeto De célula .

Valor de retorno

Célula()

Comentários

A propriedade Precedentes devolve uma matriz das células que fazem com que o objeto Célula principal recalcule o respetivo valor quando a fórmula ou o valor é alterado.

Exemplo

A seguinte macro do Microsoft Visual Basic for Applications (VBA) mostra como utilizar a propriedade Precedentes para apresentar uma lista de células nas quais a célula "Scratch.X1" de uma forma depende. A macro desenha um retângulo na página ativa, adiciona uma secção Rascunho à Folha de Formas do retângulo e, em seguida, introduz uma fórmula numa célula dessa secção que é utilizada para curvar os lados do retângulo para dentro, alterando cada um dos lados dos retângulos para um arco. Uma vez que a fórmula utilizada para curvar os lados do retângulo depende da largura e altura do retângulo, a célula que contém a fórmula Scratch.X1 depende das células Largura e Altura da forma do retângulo, tornando estas células precedentes.

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

Suporte e comentários

Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.