The key to placing a Shape object precisely is to define its Anchor,
which is a Range object within the text. Then the Top and Left
properties are measured from that anchor point. If you fail to define
an anchor, VBA assumes you meant to place it at the top left corner of
the page, which is almost never correct.
Here's some sample code for placing a Shape 0.5 inch to the right and
0.1 inch above the current cursor location, and then sizing the Shape
and setting its wrapping to Square:
Sub demo()
Dim oShp As Shape
Dim oRg As Range
Set oRg = Selection.Range
oRg.Collapse wdCollapseStart
Set oShp = ActiveDocument.Shapes.AddPicture( _
FileName:="C:\bunnycakes.jpg", _
LinkToFile:=False, _
SaveWithDocument:=True, _
Left:=InchesToPoints(0.5), _
Top:=InchesToPoints(-0.1), _
Anchor:=oRg)
' Left and Top are relative to the anchor
With oShp
.WrapFormat.Type = wdWrapSquare
.LockAspectRatio = msoTrue
.Width = InchesToPoints(2.5)
End With
End Sub
Variations on this would be to define the range differently, to make
the Shape by calling the .ConvertToShape method of an existing
InlineShape, resizing the .Width and .Height separately, etc.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
>Thanks for you reply,
>
[quoted text clipped - 34 lines]
>> >
>> >Jeff.