Shape.CellsU 属性 (Visio)

返回代表 ShapeSheet 单元格的 Cell 对象。 此为只读属性。

语法

expressionCellsU( _localeIndependentCellName_ )

表达 一个代表 Shape 对象的变量。

参数

名称 必需/可选 数据类型 说明
localeIndependentCellName 必需 字符串 ShapeSheet 单元格的名称。

返回值

Cell

备注

CellsU (“somestring”) 如果“somestring”未命名实际单元格,则会引发“意外的文件结尾”异常。 使用 CellExistsU 属性可确定是否存在具有通用名称“somestring”的单元格。

形状的“User-Defined Cells”和“Shape Data”内容中的单元格属于已经由用户或程序指定名称的行。 使用 CellsU 属性访问命名行中的单元格。

例如,如果“Row_1”是形状的“User-Defined Cells”内容中一行的名称,可以使用以下语句访问此行中的第一个单元格(零列中的单元格,其中包含该行的名称):

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

使用此语句访问 Row_1 中的提示单元格:

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

接下来,假定 Row_1 在“Shape Data”内容中而不是在“User- Defined Cells”内容中。 使用此语句访问行中的第一个单元格 (第 0 列中的单元格,该单元格保存) 行的名称:

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

使用此语句访问行中的其他单元格:

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

其中 xxx 是下列单元格之一:Label、Prompt、SortKey、Type、Format、Invisible 或 Ask。

注意

从 Microsoft Visio 2000 开始,您可以使用本地名称和通用名称来引用 Visio 形状、主控形状、文档、页面、行、加载项、单元格、超链接、样式、字体、主控形状快捷方式、UI 对象和图层。 例如,当用户命名形状时,用户将指定一个本地名称。 从 Microsoft Office Visio 2003 开始,ShapeSheet 电子表格在单元格公式和值中只显示通用名称。 (在以前的版本中,通用名称在用户界面中不可见。

) 作为开发人员,如果您不希望每次本地化解决方案时都更改名称,可以在程序中使用通用名称。 通过使用单元格的本地名称,您可以使用 Cells 属性来获取 Cell 对象。 通过使用单元格的通用名称,您可以使用 CellsU 属性来获取 Cell 对象。

示例

以下 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用 CellsU 属性通过特定 ShapeSheet 单元格的通用名称来获取该单元格。 该宏在页面上绘制一个矩形,然后通过将该形状的线条更改为弧形使矩形的线条成为弓形或曲线。 其方法是将矩形各边的 ShapeSheet 行类型由 LineTo 更改为 ArcTo,然后更改各行中的 X 和 Y 单元格的值。

 
Public Sub CellsU_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.CellsU(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

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。