Hi, I have a document where there are floating shapes (text boxes). I wrote the following macro to adjust these text boxes.
Code:
Sub Textbox()
Dim i As Integer
Dim sh As ShapeRange
Set sh = ActiveDocument.Range.ShapeRange
For i = 1 To ActiveDocument.Shapes.Count
If sh(i).Type = 17 And sh(i).AutoShapeType = 1 Then
sh(i).Select
With Selection.ShapeRange
.RelativeHorizontalPosition = wdRelativeHorizontalPositionLeftMarginArea
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.RelativeHorizontalSize = wdRelativeHorizontalSizeMargin
.RelativeVerticalSize = wdRelativeVerticalSizeMargin
.Left = CentimetersToPoints(1.7)
.LeftRelative = wdShapePositionRelativeNone
.TopRelative = wdShapePositionRelativeNone
.WidthRelative = wdShapeSizeRelativeNone
.HeightRelative = wdShapeSizeRelativeNone
.LockAnchor = True
.TextFrame.WordWrap = True
.RelativeVerticalPosition =WdRelativeVerticalPosition.wdRelativeVerticalPositionParagraph
End With
End If
Next
End Sub
It aligns the text boxes to the left of the page, straight from their current position. All my text box's anchors are locked and I was wondering if they could be Horizontally aligned as the above macro does and also align them vertically to the position where they are anchored. I have attached a screenshot, first one is of the original, after running the above macro it looks like the second image, and the third image is the final result I want to achieve.
Thanks,
Bikram