Appendix B. The Shape Object

In this appendix, I take a brief look at the issue of drawing pictures using VBA code. Since this subject is not fundamental to Word VBA programming, I will be very brief, but this introduction will give you the necessary background for further study using the VBA help files.

The Shape and InLineShape Objects

Each Word document has two layers: the text layer and the drawing layer.A Shape object is a drawing object that is placed in the drawing layer of a document. As you will see, a Shape object is anchored to a Range object (on the text layer) and its position is determined by giving its distance from that Range object.

On the other hand, an InLineShape object is a drawing object that is placed on the text layer. It is therefore treated like a character, in the sense that it moves with the surrounding text. Note that InLineShape objects are restricted to pictures, OLE objects, and ActiveX controls only, whereas there are many other types of Shape objects.

As usual, the Shape objects for a document are stored in a Shapes collection and the InLineShape objects are stored in the InLineShapes collection.

Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.