Shapes 接口

定义

对象的集合 Shape ,这些对象代表文档中的所有形状或文档中所有页眉和页脚中的所有形状。A collection of Shape objects that represent all the shapes in a document or all the shapes in all the headers and footers in a document.

public interface class Shapes : System::Collections::IEnumerable
[System.Runtime.InteropServices.Guid("0002099F-0000-0000-C000-000000000046")]
public interface Shapes : System.Collections.IEnumerable
type Shapes = interface
    interface IEnumerable
Public Interface Shapes
Implements IEnumerable
属性
实现

注解

每个 Shape 对象代表对象在绘图层中,如自选图形、 任意多边形、 OLE 对象或图片。Each Shape object represents an object in the drawing layer, such as an AutoShape, freeform, OLE object, or picture.

注释 如果要处理文档中的一部分形状(例如,只对文档中的自选图形或只对选定的形状执行某些操作),则必须构造一个 ShapeRange 包含要使用的形状的集合。 Note If you want to work with a subset of the shapes on a document— for example, to do something to only the AutoShapes on the document or to only the selected shapes— you must construct a ShapeRange collection that contains the shapes you want to work with.

使用 Shapes 属性返回Shapes集合。Use the Shapes property to return the Shapes collection.

注释 如果要同时对文档中的所有形状执行某些操作(如删除或设置属性),请使用 Range(Object) 方法创建一个ShapeRange对象,该对象包含shapes集合中的所有形状,然后对ShapeRange对象应用相应的属性或方法。 Note If you want to do something (like delete or set a property) to all the shapes on a document at the same time, use the Range(Object) method to create a ShapeRange object that contains all the shapes in the Shapes collection, and then apply the appropriate property or method to the ShapeRange object.

使用Shapes集合的下列方法之一:、、、、、、、、 AddCallout(MsoCalloutType, Single, Single, Single, Single, Object) AddCurve(Object, Object) 或。 AddLabel(MsoTextOrientation, Single, Single, Single, Single, Object) AddLine(Single, Single, Single, Single, Object) AddOLEControl(Object, Object, Object, Object, Object, Object) AddOLEObject(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) AddPolyline(Object, Object) AddShape(Int32, Single, Single, Single, Single, Object) AddTextbox(MsoTextOrientation, Single, Single, Single, Single, Object) AddTextEffect(MsoPresetTextEffect, String, String, Single, MsoTriState, MsoTriState, Single, Single, Object) BuildFreeform(MsoEditingType, Single, Single) 若要将形状添加到文档中,并返回一个shape对象,该对象表示新创建的形状。Use one of the following methods of the Shapes collection: AddCallout(MsoCalloutType, Single, Single, Single, Single, Object), AddCurve(Object, Object), AddLabel(MsoTextOrientation, Single, Single, Single, Single, Object), AddLine(Single, Single, Single, Single, Object), AddOLEControl(Object, Object, Object, Object, Object, Object), AddOLEObject(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object), AddPolyline(Object, Object), AddShape(Int32, Single, Single, Single, Single, Object), AddTextbox(MsoTextOrientation, Single, Single, Single, Single, Object), AddTextEffect(MsoPresetTextEffect, String, String, Single, MsoTriState, MsoTriState, Single, Single, Object), or BuildFreeform(MsoEditingType, Single, Single) to add a shape to a document and return a Shape object that represents the newly created shape.

使用Shapesindex ),其中 index 是名称或索引号,返回单个Shape对象。Use Shapes(index), where index is the name or the index number, to return a single Shape object.

每个形状创建时分配一个默认名称。Each shape is assigned a default name when it is created. 例如,如果向文档中添加了三个不同的形状,它们可能会被命名为"矩形 2、"文本框 3"和"椭圆 4。For example, if you add three different shapes to a document, they might be named "Rectangle 2," "TextBox 3," and "Oval 4." 若要为形状指定更有意义的名称,请设置 Name 属性。To give a shape a more meaningful name, set the Name property.

Shapes 集合不包含 InlineShape 对象。The Shapes collection does not include InlineShape objects. InlineShape 对象被视为字符,并作为字符置于文本行中。InlineShape objects are treated like characters and are positioned as characters within a line of text. Shape 对象锁定到某一文本范围,但可以自由浮动,并且可以放置在页面上的任何位置。Shape objects are anchored to a range of text but are free-floating and can be positioned anywhere on the page. 您可以使用 ConvertToInlineShape() 方法和 ConvertToShape(Object) 方法将形状从一种类型转换为另一种类型。You can use the ConvertToInlineShape() method and the ConvertToShape(Object) method to convert shapes from one type to the other. 您可以将图片、 OLE 对象和 ActiveX 控件转换为嵌入式图形。You can convert only pictures, OLE objects, and ActiveX controls to inline shapes.

Count在文档中,此集合的属性返回的只是正文中的项目数。The Count property for this collection in a document returns the number of items in the main story only. 若要对所有页眉和页脚中的形状进行计数,请将shapes集合与任何对象一起使用 HeaderFooterTo count the shapes in all the headers and footers, use the Shapes collection with any HeaderFooter object.

属性

Application

返回一个 Application 代表 Microsoft Word 应用程序的对象。Returns a Application object that represents the Microsoft Word application.

Count

返回指定集合中的项目数。Returns the number of items in the specified collection.

Creator

返回一个 32 位整数,它指示在其中创建指定的对象的应用程序。Returns a 32-bit integer that indicates the application in which the specified object was created.

Item[Object]

返回集合中的单个对象。Returns an individual object in a collection.

Parent

返回一个对象,代表指定对象的父对象。Returns an object that represents the parent object of the specified object.

方法

AddCallout(MsoCalloutType, Single, Single, Single, Single, Object)

向文档中添加无边框的线形标注。Adds a borderless line callout to a document. 返回一个 Shape 对象,该对象表示标注并将其添加到 Shapes 集合中。Returns a Shape object that represents the callout and adds it to the Shapes collection.

AddCanvas(Single, Single, Single, Single, Object)

在文档中添加绘图画布。Adds a drawing canvas to a document. 返回一个 Shape 对象,该对象代表绘图画布并将其添加到 Shapes 集合中。Returns a Shape object that represents the drawing canvas and adds it to the Shapes collection.

AddChart(XlChartType, Object, Object, Object, Object, Object)

此对象、成员或枚举已被弃用并且不适合在您的代码中使用。This object, member, or enumeration is deprecated and is not intended to be used in your code.

AddChart2(Int32, XlChartType, Object, Object, Object, Object, Object, Object)

向文档添加图表。Adds a chart to the document. 返回一个 Shape 对象,该对象表示一个图表并将其添加到指定的集合。Returns a Shape object that represents a chart and adds it to the specified collection.

AddConnector(MsoConnectorType, Single, Single, Single, Single)

仅供内部使用。Reserved for internal use.

AddCurve(Object, Object)

返回一个 Shape 对象,表示文档中的贝赛尔曲线。Returns a Shape object that represents a Bézier curve in a document.

AddDiagram(MsoDiagramType, Single, Single, Single, Single, Object)

返回一个 Shape 对象,表示文档中新创建的图表。Returns a Shape object that represents a newly created diagram in a document.

AddLabel(MsoTextOrientation, Single, Single, Single, Single, Object)

向文档中添加文本标签。Adds a text label to a document. 返回一个 Shape 对象,表示该文本标签并将其添加到 Shapes 集合中。Returns a Shape object that represents the text label and adds it to the Shapes collection.

AddLine(Single, Single, Single, Single, Object)

向文档中添加一条线。Adds a line to a document. 返回一个 Shape 代表该行并将其添加到集合中的对象 AddCallout(MsoCalloutType, Single, Single, Single, Single, Object)Returns a Shape object that represents the line and adds it to the AddCallout(MsoCalloutType, Single, Single, Single, Single, Object) collection.

AddOLEControl(Object, Object, Object, Object, Object, Object)

创建一个 ActiveX 控件(以前称为 OLE 控件)。Creates an ActiveX control (formerly known as an OLE control). 返回 Shape 表示新的 ActiveX 控件的对象。Returns the Shape object that represents the new ActiveX control.

AddOLEObject(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)

创建一个 OLE 对象。Creates an OLE object. 返回 Shape 代表新 OLE 对象的对象。Returns the Shape object that represents the new OLE object.

AddPicture(String, Object, Object, Object, Object, Object, Object, Object)

在文档中添加一幅图片。Adds a picture to a document. 返回一个 Shape 对象,该对象代表图片并将其添加到 Shapes 集合中。Returns a Shape object that represents the picture and adds it to the Shapes collection.

AddPolyline(Object, Object)

向文档中添加一个开放的或封闭的多边形。Adds an open or closed polygon to a document. 返回一个 Shape 对象,该对象表示多边形并将其添加到 Shapes 集合中。Returns a Shape object that represents the polygon and adds it to the Shapes collection.

AddShape(Int32, Single, Single, Single, Single, Object)

向某文档中添加一个自选图形。Adds an AutoShape to a document. 返回一个 Shape 对象,该对象代表自选图形并将其添加到 Shapes 集合中。Returns a Shape object that represents the AutoShape and adds it to the Shapes collection.

AddSmartArt(SmartArtLayout, Object, Object, Object, Object, Object)

将指定 SmartArt 图形插入活动文档。Inserts the specified SmartArt graphic into the active document.

AddTextbox(MsoTextOrientation, Single, Single, Single, Single, Object)

向文档中添加文本框。Adds a text box to a document. 返回一个 Shape 对象,该对象表示文本框并将其添加到 Shapes 集合中。Returns a Shape object that represents the text box and adds it to the Shapes collection.

AddTextEffect(MsoPresetTextEffect, String, String, Single, MsoTriState, MsoTriState, Single, Single, Object)

向文档中添加一个 "艺术字" 图形。Adds a WordArt shape to a document. 返回一个 Shape 对象,该对象代表艺术字并将其添加到 Shapes 集合中。Returns a Shape object that represents the WordArt and adds it to the Shapes collection.

AddWebVideo(String, Object, Object, Object, Object, Object, Object, Object, Object, Object)

向文档中添加新的 web 视频。Adds a new web video to the document.

BuildFreeform(MsoEditingType, Single, Single)

建立任意多边形对象。Builds a freeform object. 返回一个 FreeformBuilder 对象,表示正在生成的任意多边形。Returns a FreeformBuilder object that represents the freeform as it is being built.

GetEnumerator()
Range(Object)

返回一个 ShapeRange 对象。Returns a ShapeRange object.

SelectAll()

选择主要文章、画布或文档的页眉和页脚中的所有形状。Selects all the shapes in the main story, in a canvas, or in headers and footers of a document.

适用于