Class WrapFormat (Word VBA)

The class WrapFormat represents all the properties for wrapping text around a shape or shape range. To use a WrapFormat class variable it first needs to be instantiated, for example


Dim wft as WrapFormat
Set wft = ActiveDocument.Background.WrapFormat

AllowOverlap

Returns or sets a value that specifies whether a given shape can overlap other shapes.

This property can be set to either True or False. Because HTML doesn't support overlapping tables or shapes, AllowOverlap is ignored in web layout view.


ActiveDocument.Shapes(1).WrapFormat.AllowOverlap = True

DistanceBottom

Returns or sets the distance (in points) between the document text and the bottom edge of the text-free area surrounding the specified shape.

The size and shape of the specified shape, together with the values of the Type and Side properties of the WrapFormat object, determine the size and shape of this text-free area.


With ActiveDocument.Tables(1).Rows 
 .WrapAroundText = True 
 .DistanceLeft = 20 
 .DistanceRight = 20 
 .DistanceTop = 20 
 .DistanceBottom = 20 
End With

DistanceLeft

Returns or sets the distance (in points) between the document text and the left edge of the text-free area surrounding the specified shape.

The size and shape of the specified shape, together with the values of the Type and Side properties of the WrapFormat object, determine the size and shape of this text-free area.


With ActiveDocument.Tables(1).Rows 
 .WrapAroundText = True 
 .DistanceLeft = 20 
 .DistanceRight = 20 
 .DistanceTop = 20 
 .DistanceBottom = 20 
End With

DistanceRight

Returns or sets the distance (in points) between the document text and the right edge of the text-free area surrounding the specified shape.

The size and shape of the specified shape, together with the values of the Type and Side properties of the WrapFormat object, determine the size and shape of this text-free area.


With ActiveDocument.Tables(1).Rows 
 .WrapAroundText = True 
 .DistanceLeft = 20 
 .DistanceRight = 20 
 .DistanceTop = 20 
 .DistanceBottom = 20 
End With

DistanceTop

Returns or sets the distance (in points) between the document text and the top edge of the text-free area surrounding the specified shape.

The size and shape of the specified shape, together with the values of the Type and Side properties of the WrapFormat object, determine the size and shape of this text-free area.


With ActiveDocument.Tables(1).Rows 
 .WrapAroundText = True 
 .DistanceLeft = 20 
 .DistanceRight = 20 
 .DistanceTop = 20 
 .DistanceBottom = 20 
End With

Side

Returns or sets a value that indicates whether the document text should wrap on both sides of the specified shape, on either the left or right side only, or on the side of the shape that's farthest from the page margin.Read/write WdWrapSideType. Possible return values are wdWrapBoth - Both sides of the specified shape, wdWrapLargest - Side of the shape that is farthest from the page margin, wdWrapLeft - Left side of shape only, wdWrapRight - Right side of shape only.

If the text wraps on only one side of the shape, there is a text-free area between the other side of the shape and the page margin.


Set myOval = ActiveDocument.Shapes.AddShape(msoShapeOval, _ 
 0, 0, 200, 50) 
With myEll.WrapFormat 
 .Type = wdWrapSquare 
 .Side = wdWrapBoth 
 .DistanceTop = InchesToPoints(0.1) 
 .DistanceBottom = InchesToPoints(0.1) 
 .DistanceLeft = InchesToPoints(0.1) 
 .DistanceRight = InchesToPoints(0.1) 
End With

Type

Returns the wrap type for the specified shape. Possible return values are wdWrapBehind - Places shape behind text, wdWrapFront - Places shape in front of text, wdWrapInline - Places shapes in line with text, wdWrapNone - Places shape in front of text. See also wdWrapFront, wdWrapSquare - Wraps text around the shape. Line continuation is on the opposite side of the shape, wdWrapThrough - Wraps text around the shape, wdWrapTight - Wraps text close to the shape, wdWrapTopBottom - Places text above and below the shape.


ActiveDocument.Background.WrapFormat.Type = wdWrapBehind