Notifications
Clear all

[Solved] How to resize all images in a document

1 Posts
1 Users
2 Likes
2,979 Views
1
Topic starter

"In a Word document I have multiple images that I all want to resize. Since these images don't always have the same aspect ratio, I want to resize them by giving all of them the same width. The height should then adapt automatically depending on the aspect ration of each picture. I tried to select all images holding down the CTRL key  but it seems that the multi-select function is not working for images. So I can always only select one at a time and resize it and then I have to repeat this step for every single image which takes way too long.

How can I resize all images in the document at once?"

 

This topic was modified 11 months ago 2 times by Leon
1 Answer
1
Topic starter

MS Word actually does offer multiselect for images but only if the images have a text wrapping option activated and not the default “In Line with Text” option. So, in case your images have some sort of text wrapping then option 1 will work but option 2 might still be easier (and works for any kind of image setting). And if you want to fully automate the resizing process with a simple macro, then have a look at option 3.

Option 1: Select all images one-by-one and afterwards resize them all at once

(only works if images have text-wrapping activated / are not set to "In Line with Text")

  1. Hold down the CTRL key
  2. Select all images
  3. Go to the "Format" tab and in the "Size" section set a desired width for all pictures at once

 

Option 2: Resize first image and then one-by-one select the next image and repeat the last action

(works for both text-wrapping and "In Line with Text")

  1. Select the first image
  2. Go to the "Format" tab and in the "Size" section set a desired width for the image
  3. Select the next image and press the F4 key on your keyboard
  4. Repeat the last step for all images in your document

Note: The F4 key is a handy tool which repeats the last performed action. So it is not only useful for this task but also for a lot of other tasks you might have in the future.

 

Option 3: Use a macro to resize all images at once automatically

Both of the previous options will require you to go through the whole document and select every picture (manually) at least once. If you have a lot of pictures and want to speed up the process, then use a macro:

  1. Go to "File" > "Options" > "Customize Ribbon" and activate the "Developer" tab
  2. Switch to the "Developer" tab, click on "Macros", enter a new macro name (e.g. "resize") and click on "Create"
  3. In the VBA editor enter the code from below between the "Sub resize()" and "End Sub()" statement
  4. Close the VBA window
  5. Again in the "Developer" tab, click on "Macros", select the newly created macro and then click on "Run"

 

Macro code

If your images are inserted "in line with text":

Dim i As Long
With ActiveDocument
	For i = 1 To .InlineShapes.Count
		With .InlineShapes(i)
			.LockAspectRatio = msoTrue
                        'set either the width or the height and delete the line you don't need
			.Width = CentimetersToPoints(5)
			.Height = CentimetersToPoints(5)
		End With
	Next i
End With

If your images have text wrapping activated:

Dim i As Long
With ActiveDocument
        For i = 1 To .Shapes.Count
            If .Shapes(i).Type = msoPicture Then
                With .Shapes(i)
                    .LockAspectRatio = msoTrue
                    'set either the width or the height and delete the line you don't need
		    .Width = CentimetersToPoints(5)
		    .Height = CentimetersToPoints(5)
                End With
            End If
        Next i
End With

Explanation

The code loops through all (in-line) shapes in the document. If the images have text wrapping activated it also loops through standard shapes, so we need to make sure that the current shape in the loop really is an image:

If .Shapes(i).Type = msoPicture Then

Then it locks the aspect ratio of that current object, so that the object won't be visually distorted when resizing either the width or the height:

.LockAspectRatio = msoTrue

Afterwards it sets the width or the height (choose one and delete the other line) for the image in centimeters:

.Width = CentimetersToPoints(5)
.Height = CentimetersToPoints(5)

 

 

This post was modified 11 months ago 2 times by Leon
Share: