How to get and set AutoShape location on a Drawing Canvas with VBA

P

pstatham

Can anyone tell me how to get and set a shape's location on a drawing
canvas using VBA? I am using Word 2002 (Office XP) and whenever I read
the Left and Top attributes of a shape that is on a canvas, they are
always the same value as the Left and Top attributes of the canvas
itself. When I try to set the values of the Left and Top attributes,
they seem to be ignored.

Here is the VBA code I am using to debug the issue:

Sub ShowAllShapes()
Dim shp As Shape
Dim ci As Shape


For Each shp In Documents("Doc5.doc").Shapes
ShowShape shp
If shp.type = msoCanvas Then
For Each ci In shp.CanvasItems
ShowShape ci
Next ci
End If
Next shp
End Sub

Sub ShowShape(shp As Shape)
shp.Select
Debug.Print "Type=" & shp.type
Debug.Print " Left=" & shp.Left _
& ", Top=" & shp.Top _
& ", Height=" & shp.Height _
& ", Width=" & shp.Width _
& ", RelativeHorizontalPosition=" &
shp.RelativeHorizontalPosition _
& ", RelativeVerticalPosition=" &
shp.RelativeVerticalPosition
Debug.Print
End Sub

TIA -
Perry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top