Table of contents
TOC
折叠目录
展开目录

Style.Cells 属性 (Visio)Style.Cells Property (Visio)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

返回一个Cell对象,该对象代表 ShapeSheet 单元格。只读的。Returns a Cell object that represents a ShapeSheet cell. Read-only.

语法Syntax

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

表达式_一个表示样式对象的变量。_expression A variable that represents a Style object.

参数Parameters

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

返回值Return Value

CellCell

注解Remarks

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

形状的用户定义的单元格和形状数据部分中的单元格所属的行已由用户或程序分配的名称。Cells属性用于访问已命名行中的单元格。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. 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_是一个单元格区域: 标签,提示、 关键字、 类型、 格式、 不可见或提出。where xxx is one of these cells: Label, Prompt, SortKey, Type, Format, Invisible, or Ask.

请注意 从 Microsoft Visio 2000 开始,可以使用本地和通用名称来指代 Visio 形状、 主控形状、 文档、 页面、 行、 加载项、 单元格、 超链接、 样式、 字体、 主控形状快捷方式、 用户界面对象和图层。当用户为某个形状命名时,例如,用户指定的本地名称。从 Microsoft Office Visio 2003 开始,ShapeSheet 电子表格中单元格的公式和值显示只有通用名称。(在先前版本中,通用名称都不可见的用户界面中。)Note 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. 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.)

作为开发人员,您可以在程序中使用通用名称时,您不希望每次本地化解决方案时都更改名称。Cells属性用于获取Cell对象使用单元格的本地名称。使用CellsU属性来获取Cell对象通过使用单元格的通用名称。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. Use the Cells property to get a Cell object by using the cell's local name. Use the CellsU property to get a Cell object by using the cell's universal name.

示例Example

(VBA) 宏此 Microsoft Visual Basic for Applications 演示如何使用单元格的属性按名称获取特定 ShapeSheet 单元格。它上一个页,成为弓形绘制矩形或曲线通过将该形状的线条更改为弧形使矩形的线条。这被通过将每个矩形边的形状表行类型从线条更改为 ArcTo,然后更改每个这些行中的 X 和 Y 单元格的值。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. 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
© 2018 Microsoft