Propriedade Cell.Formula (Visio)

Obtém ou define a fórmula de um objeto Cell. Leitura/gravação.

Sintaxe

expressão. Fórmula

Expressão Uma variável que representa um objeto Cell .

Valor de retorno

Cadeia de caracteres

Comentários

Se a fórmula de uma célula estiver protegida pela função GUARD, você terá que usar a propriedade FormulaForce para alterá-la.

Observação

A partir do Microsoft Visio 2000, você pode usar nomes locais e universais para se referir a formas, mestres, documentos, páginas, linhas, complementos, células, hiperlinks, estilos, fontes, atalhos mestre, objetos UI e camadas do Visio. Quando um usuário nomeia uma forma, por exemplo, o usuário está especificando um nome local. A partir do Microsoft Office Visio 2003, a planilha ShapeSheet exibe apenas nomes universais em fórmulas de células e valores. (Em versões anteriores, os nomes universais não eram visíveis na interface do usuário.).

Como desenvolvedor, você poderá usar nomes universais em um programa quando não quiser alterar um nome a cada vez que uma solução for localizada. Use a propriedade Formula para obter a cadeia de caracteres da fórmula de uma célula em sintaxe local ou para usar uma combinação de sintaxe local e universal para defini-la. Use a propriedade FormulaU para obter ou analisar uma fórmula em sintaxe universal. Se a propriedade FormulaU for utilizada, o ponto decimal sempre será ".", o delimitador sempre será "," e você deverá usar cadeias de caracteres universais de unidades (para obter mais detalhes sobre cadeias de caracteres universais, consulte Sobre Unidades de Medida).

Exemplo

Esta macro do VBA (Microsoft Visual Basic for Applications) mostra como usar a propriedade Formula para definir a fórmula de uma célula ShapeSheet. Ela desenha um retângulo na página e arqueia ou curva as linhas do retângulo alterando as linhas da forma para arcos. Em seguida, ela desenha um retângulo interno delimitado pelas linhas curvas do primeiro retângulo.

 
Public Sub Formula_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

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.