I'm trying to write a VBA macro in Word that will extract shapes and build them in Visio. I'm having some trouble getting the X Y coordinates of the shape in the document. I have tried using the Top and Left properties of the shape objects. The Left property seems to work fine, but the Top doesn't seem to work properly. A shape near the top of the page can have the same top as a shape at the bottom, so the top doesn't seem to apply to the Y coordinate, which doesn't make sense to me.
Any thoughts or suggestions?
Jon, the "Top" property should update as the shape changes location. Are you running a script similar to this:
Sub getShapeXY()
Dim shp As Shape
Set shp = ThisDocument.Shapes(1)
shpOffsetX = shp.Left
shpWidth = shp.Width
x = shpOffsetX + shpWidth
shpOffsetY = shp.Top
shpHeight = shp.Height
y = shpOffsetY + shpHeight
Debug.Print shpOffsetX & ": OffsetX, " & shpWidth & ": Width, " & x & ": X"
Debug.Print shpOffsetY & ": OffsetY, " & shpHeight & ": Height, " & y & ": Y"
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With