Mikk
08-17-2016, 04:29 AM
Hello everyone,
I tried to solve this for quite some time now but I just cant find out how nor found hints online so far.
My question is how can I position a shape aligned vertically to the bottom of the page like this via VBA:
16888
Whatever I tried in VBA will always result in absolute positions like -28cm below page.
We want the Alignment mode so that our shape will not be positioned wrong when paper size is changed by the user.
My not working code so far looks like this:
'myrange is a header
Set picShape = myrange.InlineShapes.AddPicture(FileName:=strFile, LinkToFile:=False, SaveWithDocument:=True, range:=myrange).ConvertToShape
With picShape
.LockAspectRatio = True
.Height = MillimetersToPoints(15)
.WrapFormat.Type = wdWrapFront
.ZOrder msoBringToFront
.RelativeHorizontalPosition = wdRelativeHorizontalPositionRightMarginArea
.Left = -picShape.Width + MillimetersToPoints(1)
End With
picShape.Select
Dim shpr As ShapeRange
Set shpr = Selection.ShapeRange
shpr.RelativeVerticalPosition = wdRelativeVerticalPositionPage
shpr.Align msoAlignBottoms, True
the result then looks like this:
16889
Thanks in advance!
Mikk
I tried to solve this for quite some time now but I just cant find out how nor found hints online so far.
My question is how can I position a shape aligned vertically to the bottom of the page like this via VBA:
16888
Whatever I tried in VBA will always result in absolute positions like -28cm below page.
We want the Alignment mode so that our shape will not be positioned wrong when paper size is changed by the user.
My not working code so far looks like this:
'myrange is a header
Set picShape = myrange.InlineShapes.AddPicture(FileName:=strFile, LinkToFile:=False, SaveWithDocument:=True, range:=myrange).ConvertToShape
With picShape
.LockAspectRatio = True
.Height = MillimetersToPoints(15)
.WrapFormat.Type = wdWrapFront
.ZOrder msoBringToFront
.RelativeHorizontalPosition = wdRelativeHorizontalPositionRightMarginArea
.Left = -picShape.Width + MillimetersToPoints(1)
End With
picShape.Select
Dim shpr As ShapeRange
Set shpr = Selection.ShapeRange
shpr.RelativeVerticalPosition = wdRelativeVerticalPositionPage
shpr.Align msoAlignBottoms, True
the result then looks like this:
16889
Thanks in advance!
Mikk