Style。 Cells 属性 (Visio)Style.Cells property (Visio)

返回一个Cell对象, 该对象表示一个 ShapeSheet 单元格。Returns a Cell object that represents a ShapeSheet cell. 此为只读属性。Read-only.

语法Syntax

表达式单元格(localeSpecificCellName)expression.Cells (localeSpecificCellName)

_表达式_一个代表**Style** 对象的变量。expression A variable that represents a Style object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
localeSpecificCellNamelocaleSpecificCellName 必需Required StringString ShapeSheet 单元格的名称。The name of a ShapeSheet cell.

返回值Return value

CellCell

说明Remarks

单元格("somestring") 如果 "somestring" 不命名实际单元格, 则会引发 "意外的文件结尾" 异常。Cells ("somestring") raises an "Unexpected end of file" exception if "somestring" does not name an actual cell. 可以使用 CellExists 属性确定是否存在名称为“somestring”的单元格。You can use the CellExists property to determine if a cell with the name "somestring" exists.

形状的“User-Defined Cells”和“Shape Data”内容中的单元格属于已经由用户或程序指定名称的行。The cells in a shape's User-Defined Cells and Shape Data sections belong to rows whose names have been assigned by the user or a program. 可以使用Cells属性来访问已命名的行中的单元格。You can use the Cells property to access cells in named rows.

例如,如果“Row_1”是形状的“User-Defined Cells”内容中一行的名称,可以使用以下语句访问此行中的第一个单元格(零列中的单元格,其中包含该行的名称):For example, if "Row_1" is the name of a row in a shape's User-Defined Cells section, you can use this statement to access the first cell in this row (the cell in column zero, which holds the name of the row):

vsoCell = vsoShape.Cells("User.Row_1")

可以使用以下语句访问 Row_1 中的 Prompt 单元格:You can use this statement to access the prompt cell in Row_1:

vsoCell = vsoShape.Cells("User.Row_1.Prompt")

接下来,假定 Row_1 在“Shape Data”内容中而不是在“User- Defined Cells”内容中。Next, assume that Row_1 is in the Shape Data section instead of the User- Defined Cells section. 可以使用以下语句访问该行中的第一个单元格(零列中的单元格,其中包含该行的名称):You can use this statement to access the first cell in this row (the cell in column zero, which holds the name of the row):

vsoCell = vsoShape.Cells("Prop.Row_1")

可以使用以下语句访问此行中的其他单元格:You can use this statement to access other cells in the row:

vsoCell = vsoShape.Cells("Prop.Row_1.xxx")

其中_xxx_是以下单元格之一: Label、Prompt、SortKey、Type、Format、不可见或 Ask。where xxx is one of these cells: Label, Prompt, SortKey, Type, Format, Invisible, or Ask.

备注

从 Microsoft Visio 2000 开始,您可以使用本地名称和通用名称来引用 Visio 形状、主控形状、文档、页面、行、加载项、单元格、超链接、样式、字体、主控形状快捷方式、UI 对象和图层。Beginning with Microsoft Visio 2000, you can use both local and universal names to refer to Visio shapes, masters, documents, pages, rows, add-ons, cells, hyperlinks, styles, fonts, master shortcuts, UI objects, and layers. 例如,当用户命名形状时,用户将指定一个本地名称。When a user names a shape, for example, the user is specifying a local name. 从 Microsoft Office Visio 2003 开始,ShapeSheet 电子表格在单元格公式和值中只显示通用名称。Beginning with Microsoft Office Visio 2003, the ShapeSheet spreadsheet displays only universal names in cell formulas and values. (在以前的版本中,通用名称在用户界面中不可见。(In prior versions, universal names were not visible in the user interface.)

) 作为开发人员,如果您不希望每次本地化解决方案时都更改名称,可以在程序中使用通用名称。As a developer, you can use universal names in a program when you don't want to change a name each time a solution is localized. 通过使用单元格的本地名称,您可以使用 Cells 属性来获取 Cell 对象。Use the Cells property to get a Cell object by using the cell's local name. 通过使用单元格的通用名称,您可以使用 CellsU 属性来获取 Cell 对象。Use the CellsU property to get a Cell object by using the cell's universal name.

示例Example

以下 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用Cells属性按名称获取特定 ShapeSheet 单元格。This Microsoft Visual Basic for Applications (VBA) macro shows how to use the Cells property to get a particular ShapeSheet cell by its name. 该宏在页面上绘制一个矩形,然后通过将该形状的线条更改为弧形使矩形的线条成为弓形或曲线。It draws a rectangle on a page and bows, or curves the lines of the rectangle by changing the shape's lines to arcs. 其方法是将矩形各边的 ShapeSheet 行类型由 LineTo 更改为 ArcTo,然后更改各行中的 X 和 Y 单元格的值。This is accomplished by changing the ShapeSheet row types for each side of the rectangle from LineTo to ArcTo and then changing the values of the X and Y cells in each of these rows.

 
Public Sub Cells_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 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 and add a row to the scratch section. 
 vsoShape.AddSection visSectionScratch 
 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 
 
End Sub

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.