Propriedade Shape.CellsSRC (Visio)

Retorna um objeto Cell que representa uma célula ShapeSheet identificada por índices de seção, linha e coluna. Somente leitura.

Sintaxe

expression. CellsSRC( _Section_ , _Row_ , _Column_ )

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

Parâmetros

Nome Obrigatório/Opcional Tipo de dados Descrição
Section Obrigatório Integer O índice de seção da célula.
Linha Obrigatório Integer O índice de linha da célula.
Coluna Obrigatório Integer O índice de coluna da célula.

Valor de retorno

Cell

Comentários

Para acessar qualquer fórmula de forma por seus índices de seção, linha e coluna, use a propriedade CellsSRC. As constantes para índices de seção, linha e coluna são declaradas pela biblioteca de tipos do Visio como membros do VisSectionIndices, VisRowIndices e VisCellIndices, respectivamente.

A propriedade CellsSRC poderá gerar uma exceção se os valores de índice para seção, linha e coluna não identificarem uma célula real, dependendo da seção. No entanto, mesmo se nenhuma exceção for levantada, métodos subsequentes invocados no objeto retornado irão falhar. Você pode determinar se uma célula com valores de índice particulares existe usando a propriedade CellsSRCExists.

A propriedade CellsSRC é tipicamente usada para iterar pelas células em uma seção ou linha. Para recuperar uma única célula, use a propriedade Cells e especifique um nome de célula. Por exemplo:

Set vsoCell = Cells("PinX")

Se sua solução do Visual Studio incluir a referência Microsoft.Office.Interop.Visio , essa propriedade será mapeada para os seguintes tipos:

  • Microsoft.Office.Interop.Visio.IVShape.get_CellsSRC

Exemplo

A seguinte macro do Microsoft Visual Basic for Applications (VBA) mostra como usar a propriedade CellsSRC para definir uma célula ShapeSheet particular por seus índices de seção, linha e coluna. Ela desenha um retângulo em uma página e transforma em arcos, ou curvas, as linhas do retângulo, alterando as linhas da forma para arcos. A macro desenha, em seguida, um retângulo interno dentro das linhas curvadas do primeiro retângulo.

 
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

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.