Adding shapes in Word Document using VBA

Shapes: It is a collection which comes under Document object and requires following parameters to be set. The AddShpe method of Shapes collection will let you add shape in the document through code.

Required Parameters:

  • Type: It has MsoAutoShapeType enum which offers many constants to form various inbuilt shapes. Just put the dot and you see list of various available shapes which you can create in your document.
  • Left: Left edge of the shape
  • Top: Top edge of the shape
  • Width: Width of the shape
  • Height: Height of the shape

All parameters (Left, Top, Width, Height) are measured in points. Following code will create two arrows in different directions:

Sub InsertShap()
    ActiveDocument.Shapes.AddShape MsoAutoShapeType.msoShapeLeftArrow, 20, 50, 100, 80
    ActiveDocument.Shapes.AddShape MsoAutoShapeType.msoShapeRightArrow, 160, 50, 100, 80
End Sub


Leave a Reply

Your email address will not be published.