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

矩形对象 (PowerPoint)CellRange Object (PowerPoint)

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

表中的列或行中的单元格对象的集合。矩形集合表示在指定的列或行中的所有单元格。若要使用矩形集合,请使用单元格关键字。A collection of Cell objects in a table column or row. The CellRange collection represents all the cells in the specified column or row. To use the CellRange collection, use the Cells keyword.

注解Remarks

虽然集合对象名为矩形,并显示在对象浏览器中,未编程 PowerPoint 对象模型中使用此关键字。而使用了关键字单元格Although the collection object is named CellRange and is shown in the Object Browser, this keyword is not used in programming the PowerPoint object model. The keyword Cells is used instead.

以编程方式添加到单元格也不能删除 PowerPoint 表中的单元格。使用Table对象的AddTable方法来添加一个新表。使用的集合的Add方法可向表格中添加行或列。删除集合的方法用于从表中删除行或列。You cannot programmatically add cells to or delete cells from a PowerPoint table. Use the AddTable method with the Table object to add a new table. Use the Add method of the Columns or Rows collections to add a column or row to a table. Use the Delete method of the Columns or Rows collections to delete a column or row from a table.

示例Example

使用Cells属性可返回矩形集合。本示例设置为虚线样式表第一列中的单元格的右边框。Use the Cells property to return the CellRange collection. This example sets the right border for the cells in the first column of the table to a dashed line style.

With ActivePresentation.Slides(2).Shapes(5).Table.Columns(1).Cells

    .Borders(ppBorderRight).DashStyle = msoLineDash

End With

本示例返回选定表格中第一行的单元格数。This example returns the number of cells in row one of the selected table.

num = ActiveWindow.Selection.ShapeRange.Table.Rows(1).Cells.Count

使用单元格(行、 列),其中行是行数和列是列号或单元格(索引),其中索引中指定的行或列是该单元格的数目,以返回单个单元格对象。单元格从左到右按行,从上到列中的下编号。使用从右向左的语言设置时,此方案将反转。下面的示例将合并的行的表中第五个形状的第二张幻灯片中的前两个单元格。Use Cell (row, column), where row is the row number and column is the column number, or Cells (index), where index is the number of the cell in the specified row or column, to return a single Cell object. Cells are numbered from left to right in rows and from top to bottom in columns. With right-to-left language settings, this scheme is reversed. The example below merges the first two cells in row one of the table in shape five on slide two.

With ActivePresentation.Slides(2).Shapes(5).Table

    .Cell(1, 1).Merge MergeTo:=.Cell(1, 2)

End With

另请参阅See also

概念Concepts

PowerPoint 对象模型引用PowerPoint Object Model Reference

© 2018 Microsoft