Word VBA, Shape Index

One of the things you need to know when working with shapes in VBA for word, is the shape index. Shape object are referenced through the Shapes and InlineShapes collections. In order for this to be done you must know the shape index. Shapes are indexed starting from the index “1”. Shapes fall into two main categories:

  1. Inline Shapes
  2. Floating Shapes

I have covered this topic in the article below:

A shape can be of many different types:

  • Pictures
  • Autoshape
  • Canvas
  • Comment
  • Diagram

The type of shape does not affect its indexing. I will explain how shapes are indexed using examples.


Example 1:

Assume we have the following 3 floating shapes in our document. The first shape is a picture, the second is a chart and the third is again a picture:

Shape Index

The shape indices can be seen in the table below.

Index Category Shape Type Reference
1 Floating Shape Picture Shapes.Item(1)
2 Floating Shape Chart Shapes.Item(2)
3 Floating Shape Picture Shapes.Item(3)

Example 2:

In the figure below you can see another word document. In this document there are floating and inline shapes. The chart has been changed to inline. Two text boxes have been added, the first is inline while the second is floating. Also at the end of the document there is a floating picture:

Shape Index 2
The shape indices can be seen in the table below:

Index Category Shape Type Reference
1 Floating Shape Picture Shapes.Item(1)
1 Inline Shape Chart InlineShapes.Item(1)
2 Floating Shape Picture Shapes.Item(2)
2 Inline Shape Text box InlineShapes.Item(2)
3 Floating Shape Text box Shapes.Item(3)
4 Floating Shape Picture Shapes.Item(4)

If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website  www.software-solutions-online.com

 

Leave a Reply

Your email address will not be published. Required fields are marked *