# [SOLVED] Creating a macro in word to resize an image



## simjambra (Feb 4, 2009)

Hi

I am trying to record a macro in Word 2003 which will resize an images width to 11cm.

The trouble is, the images are all different dimensions, so I need to lock the aspect ratio for the height.

Whenever I try to record a macro, it always reverts to a fixed height.

Please help.

PS I don't know any VB :laugh:


----------



## macropod (Apr 11, 2008)

*Re: Creating a macro in word to resize an image*

Hi simjambra,

You could use a macro like:

```
Sub ReformatPictures()
On Error Resume Next
Dim oShp As Shape
Dim iShp As InlineShape
Dim ShpScale As Double
With ActiveDocument
  For Each oShp In .Shapes
    With oShp
      If .Type = msoPicture Or msoLinkedPicture Then
        ShpScale = CentimetersToPoints(11) / .Width
        .Width = .Width * ShpScale
        If .LockAspectRatio = False Then .Height = .Height * ShpScale
      End If
    End With
  Next oShp
  For Each iShp In .InlineShapes
    With iShp
      If .Type = wdInlineShapePicture Or wdInlineShapeLinkedPicture Then
        ShpScale = CentimetersToPoints(11) / .Width
        .Width = .Width * ShpScale
        If .LockAspectRatio = False Then .Height = .Height * ShpScale
      End If
    End With
  Next iShp
End With
MsgBox "Finished Reformatting."
End Sub
```


----------



## simjambra (Feb 4, 2009)

*Re: Creating a macro in word to resize an image*

Oh thank you. Thank you so much.

You star ray:


----------

