Search code examples
vbams-wordcopy-pasteword-2010

Copy shape in Word 2010 without .Select?


Is it possible to copy a shape in Word 2010 without resorting to .Select? According to Dev Center the Anchor property returns the shape's anchoring range. Could that be a way forward? However, the code below returns an error.

Sub createShape()
    Set myShape = ActiveDocument.Shapes.AddShape(msoShapeRectangle, 1, 1, 1, 1)
    myShape.Anchor.Copy
End Sub

Solution

  • While it does not seem to be possible to copy a shape without selecting it, it is possible to duplicate a shape without selecting it (which was my reason for wanting to copy it in the first place). The code below gives me what I was looking for:

    Sub createShape()
        Set myshape = ActiveDocument.Shapes.AddShape(msoShapeRectangle, 100, 100, 100, 100)
        Set anothershape = myshape.Duplicate
    End Sub