I'm trying to create a macro in word 2013. My purpose is to add a picture to the current page, and than set its size and position. My problem is that I can't set it's layout options: I want it "behind text" and "fix position on page".
This is my code:
#Sub myMacro()
Set bla = ActiveDocument.Shapes.AddPicture _
(FileName:="\\\image_path///", _
LinkToFile:=False, _
SaveWithDocument:=True, _
Left:=28.34, _
Top:=500, _
Width:=107, _
Height:=107)
End Sub
#
Thanks!
You do it through bla. When you call ActiveDocument.Shapes.AddPicture it returns a Shape object. In your case you are passing it to blah and ignoring it.
To set the shape to wrap behind you can do this after creating blah:
With bla
.WrapFormat.Type = wdWrapBehind
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.Left = InchesToPoints(3.0)
.Top = InchesToPoints(4.2)
End With
wdRelativeHorizontalPositionPage
and wdRelativeVerticalPositionPage
say that coordinates are relative to the left and top of current page. Then .left specifies inches from the left edge of page and .Top is number of inches from the top.
All the available members you can call on a shape are discussed on these MSDN pages