Partager via


Propriété Shape.CellsSRC (Visio)

Renvoie un objet Cell qui représente une cellule de feuille ShapeSheet identifiée par des index de section, de ligne et de colonne. En lecture seule.

Syntaxe

expression. CellsSRC( _Section_ , _Row_ , _Column_ )

expression Une variable qui représente uneForme d’objet.

Paramètres

Nom Requis/Facultatif Type de données Description
Section Obligatoire Integer Index de section de la cellule.
Ligne Obligatoire Integer Index de ligne de la cellule.
Colonne Obligatoire Integer Index de colonne de la cellule.

Valeur renvoyée

Cell

Remarques

Pour accéder à une formule de forme en indiquant ses index de section, de ligne et de colonne, utilisez la propriété CellsSRC. Les constantes des index de section, de ligne et de colonne sont déclarées par la bibliothèque de types Visio en tant que membres de VisSectionIndices, VisRowIndices et VisCellIndices, respectivement.

La propriété CellsSRC peut lever une exception si les valeurs d’index de section, de ligne et de colonne n’identifient pas une cellule réelle, en fonction de la section. Toutefois, même si aucune exception n’est déclenchée, les autres méthodes appliquées à l’objet renvoyé échouent. Vous pouvez déterminer si une cellule avec des valeurs d’index données existe en utilisant la propriété CellsSRCExists.

La propriété CellsSRC est généralement utilisée pour effectuer une itération dans les cellules d’une section ou d’une ligne. Pour récupérer une seule cellule, utilisez la propriété Cells en indiquant un nom de cellule. Par exemple :

Set vsoCell = Cells("PinX")

Si votre solution Visual Studio comprend la référence Microsoft.Office.Interop.Visio, cette propriété est mappée avec les types suivants :

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

Exemple

La macro Microsoft Visual Basic pour Applications (VBA) suivante indique comment utiliser la propriété CellsSRC pour définir une cellule de feuille ShapeSheet particulière en fonction de ses index de section, de ligne et de colonne. Elle dessine un rectangle sur une page et courbe ses traits jusqu’à ce qu’ils deviennent des arcs. La macro dessine ensuite un rectangle à l'intérieur des traits courbés du premier rectangle.

 
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

Assistance et commentaires

Avez-vous des questions ou des commentaires sur Office VBA ou sur cette documentation ? Consultez la rubrique concernant l’assistance pour Office VBA et l’envoi de commentaires afin d’obtenir des instructions pour recevoir une assistance et envoyer vos commentaires.