![]() You can create a ShapeRange object that contains all the Shape objects on a sheet by selecting the shapes and then using the ShapeRange property to return a ShapeRange object containing the selected shapes. Creating a ShapeRange collection that contains all shapes on a sheet If you want to apply one of these properties or methods to a collection of shapes, you must loop through the collection and test each individual shape to make sure it is an appropriate type of shape before applying the property or method to it. If you are not positive that each of the shapes in a ShapeRange collection can have a certain property or method applied to it, don't apply the property or method to the ShapeRange collection. For example, the TextFrame property fails if applied to a shape that cannot contain text. Many properties and methods that apply to the Shape object and ShapeRange collection fail if applied to certain kinds of shapes. If the operation does not work on multiple selected shapes in the user interface, you can still perform the operation in Visual Basic by looping through the Shapes collection or through a ShapeRange collection that contains the shapes you want to work with, and applying the appropriate properties and methods to the individual Shape objects in the collection. If the operation works on multiple selected shapes in the user interface, you can perform the same operation in Visual Basic by constructing a ShapeRange collection that contains the shapes you want to work with, and applying the appropriate properties and methods directly to the ShapeRange collection. These two ways allow you to perform any operation that you can perform on a single shape on a range of shapes, whether or not you can perform the same operation in the user interface. ![]() In Visual Basic, there are two ways to apply properties and methods to a set of shapes. You can perform other operations with only a single shape selected for example, you can edit the text in a shape only if a single shape is selected. In the user interface, you can perform some operations with several shapes selected for example, you can select several shapes and set all their individual fills at once. ![]() Worksheets(1).Shapes(1). = RGB(255, 0, 0)Īpplying a property or method to several shapes at the same time For example, you use the Fill property to return the FillFormat object, and then you set the ForeColor property of the FillFormat object to set the fill foreground color for the specified shape, as shown in the following example. ![]() To set properties for a shape, you must first return the object that represents the set of related shape attributes and then set properties of that returned object. Instead, related shape attributes are grouped under secondary objects, such as the FillFormat object, which contains all the properties that relate to the shape's fill, or the LinkFormat object, which contains all the properties that are unique to linked OLE objects. Many formatting properties of shapes are not set by properties that apply directly to the Shape or ShapeRange object. Use to modify multiple shapes the same way you work with multiple shapes in the user interface. Use to create shapes and to iterate through all the shapes on a given worksheet. ![]() Shapes, or drawing objects, are represented by three different objects: Object ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |