Skip to content

Instantly share code, notes, and snippets.

@zwf
Last active November 15, 2017 08:45
Show Gist options
  • Save zwf/73fd20c9cfdbe45e691bdf8bbe868992 to your computer and use it in GitHub Desktop.
Save zwf/73fd20c9cfdbe45e691bdf8bbe868992 to your computer and use it in GitHub Desktop.
resize images in word docs and horizontal center by word macro
Sub ResizeAllImagesAndHorizontalCenter()
Dim oShp As Shape
Dim oILShp As InlineShape
For Each oILShp In ActiveDocument.InlineShapes
With oILShp
.ConvertToShape
End With
Next
For Each oShp In ActiveDocument.Shapes
With oShp
.Width = CentimetersToPoints(10)
.Select
If Selection.ShapeRange.Type = msoPicture Then
Selection.ShapeRange.WrapFormat.Type = wdWrapTopBottom
Selection.ShapeRange.Left = ActiveDocument.PageSetup.PageWidth / 2 - ActiveDocument.PageSetup.LeftMargin - Selection.ShapeRange.Width / 2
End If
End With
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment