Свойство Shape.CellsSRC (Visio)
Возвращает объект Cell , представляющий ячейку таблицы фигур, определяемую индексами раздела, строки и столбца. Только для чтения.
Синтаксис
выражение. CellsSRC
( _Section_
, _Row_
, _Column_
)
Выражение Переменная, представляющая объект Shape .
Параметры
Имя | Обязательный или необязательный | Тип данных | Описание |
---|---|---|---|
Section | Обязательный | Integer | Индекс раздела ячейки. |
Row | Обязательный | Integer | Индекс строки ячейки. |
Столбец | Обязательный | Integer | Индекс столбца ячейки. |
Возвращаемое значение
Cell
Замечания
Чтобы получить доступ к любой формуле фигуры по индексам раздела, строки и столбца, используйте свойство CellsSRC . Константы для индексов секций, строк и столбцов объявляются библиотекой типов Visio как члены VisSectionIndices, VisRowIndices и VisCellIndices соответственно.
Свойство CellsSRC может вызвать исключение, если значения индекса для раздела, строки и столбца не определяют фактическую ячейку в зависимости от раздела. Однако даже если исключение не возникает, последующие методы, вызываемые для возвращаемого объекта, завершаются ошибкой. Определить, существует ли ячейка с определенными значениями индекса, можно с помощью свойства CellsSRCExists .
Свойство CellsSRC обычно используется для итерации ячеек в разделе или строке. Чтобы получить одну ячейку, используйте свойство Cells и укажите имя ячейки. Например:
Set vsoCell = Cells("PinX")
Если решение Visual Studio содержит ссылку microsoft.Office.Interop.Visio , это свойство сопоставляется со следующими типами:
- Microsoft.Office.Interop.Visio.IVShape.get_CellsSRC
Пример
В следующем макросе Microsoft Visual Basic для приложений (VBA) показано, как использовать свойство CellsSRC для задания определенной ячейки Таблицы фигур по индексам раздела, строки и столбца. Он рисует прямоугольник на странице и смычки или изгибает линии прямоугольника, изменяя линии фигуры на дуги. Затем макрос рисует внутренний прямоугольник внутри наклонных линий первого прямоугольника.
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
Поддержка и обратная связь
Есть вопросы или отзывы, касающиеся Office VBA или этой статьи? Руководство по другим способам получения поддержки и отправки отзывов см. в статье Поддержка Office VBA и обратная связь.
Обратная связь
https://aka.ms/ContentUserFeedback.
Ожидается в ближайшее время: в течение 2024 года мы постепенно откажемся от GitHub Issues как механизма обратной связи для контента и заменим его новой системой обратной связи. Дополнительные сведения см. в разделеОтправить и просмотреть отзыв по