CodeDocu.com

Word macro: Spacing around images
 
This macro converts all photos and pictures in a Word document in the form,
that the photos be provided at a distance (margin) and that wraps the text around the images around.
 
All images on the type shape be changed to do this in Word vba macro and the text is assigned to the setting wdWrapSquare.
Then, distance adjusts the distance as margin.
 
Word Macro: Set all Images to left alignment with a surrounding margin
 
 
 
The complete Word macro code to free use in an own word vba programming

Sub b1_Set_Margin_Images_4()
'-----------------< b1_Set_Margin_Images_4() >-----------------
'--< Convert InlineShapes >--
Dim inlineshape As inlineshape
Dim shape_Converted As shape
While ActiveDocument.InlineShapes.Count > 0
Set inlineshape = ActiveDocument.InlineShapes(1)
'< scale >
Set shape_Converted = inlineshape.ConvertToShape()
'</ scale >
Wend
'--</ Convert InlineShapes >--

'--< Convert Shapes >--
Dim shape As shape
Dim iShape As Integer
For iShape = 1 To ActiveDocument.Shapes.Count
Set shape = ActiveDocument.Shapes(iShape)
'--< WrapFormat >--
'*set WrapFormat
'* >=Office 2013
shape.WrapFormat.Type = wdWrapSquare
'
shape.WrapFormat.AllowOverlap = 0
shape.WrapFormat.Side = wdWrapBoth
shape.WrapFormat.DistanceBottom = CentimetersToPoints(0.5)
shape.WrapFormat.DistanceLeft = CentimetersToPoints(0.5)
shape.WrapFormat.DistanceRight = CentimetersToPoints(0.5)
shape.WrapFormat.DistanceTop = CentimetersToPoints(0.5)
'--</ WrapFormat >--
 
Next
'--</ Convert Shapes >--
 
'-----------------</ b1_Set_Margin_Images_4() >-----------------
End Sub
 

 
 
Additional parameters:
' shape Word as of 2013. LayoutInCell = true indicates that a specified image within the table is displayed
' shape. LayoutInCell = true
 
' shape. RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
' shape. RelativeVerticalPosition = wdRelativeVerticalPositionLine
' shape. RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
 
' shape. Left = 0
' shape. Anchor = 0

Software Entwicklung Stuttgart NĂ¼rtingen
Suche Projekte C#, WPF, Windows App,ASP.Net, vb.Net, WinForms, SQL Server, Access, Excel