O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required