How to insert multiple pictures with same size in Word document?

Normally, you can insert multiple images into a Word document with their original sizes. However, sometimes you may need to arrange these images to have the same size upon insertion. This article will discuss how to insert multiple images with the same size in a Word document.

Insert Multiple Images with the Same Size Using VBA Code

The following VBA code can help you insert multiple images and resize them to a specified size simultaneously. Follow these steps:

  1. Press ALT + F11 to open the Microsoft Visual Basic for Application window.
  2. Click Insert > Module and paste the code below into the Module window.
Sub InsertSpecificNumberOfPictureForEachPage()
Dim xDlg As FileDialog
Dim xFilePath As String
Dim xFileName As String
Dim xMsbBoxRtn As Long
Dim xPicSize As String
Dim xShape As InlineShape
Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
If xDlg.Show = -1 Then
xFilePath = xDlg.SelectedItems(1) & “\”
Else
Exit Sub
End If
xFileName = Dir(xFilePath & “*.*”, vbNormal)
While xFileName <> “”
If Not (Right(xFileName, 4) = “.png” Or Right(xFileName, 4) = “.bmp” _
Or Right(xFileName, 4) = “.jpg” Or Right(xFileName, 4) = “.ico”) Then
GoTo LblCtn
End If
With Selection
.InlineShapes.AddPicture xFilePath & xFileName, False, True
.TypeParagraph
.Collapse wdCollapsEnd
.TypeText Left(xFileName, InStrRev(xFileName, “.”) – 1)
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.TypeParagraph
End With
LblCtn:
xFileName = Dir()
Wend
ActiveDocument.InlineShapes(1).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
xMsbBoxRtn = MsgBox(“Do you want to resize all pictures?”, vbYesNo, “Kutools for Word”)
If xMsbBoxRtn = 6 Then
xPicSize = InputBox(“Input the height and width of the picture, separated by comma”, “Kutools for Word”, “”)
End If
For Each xShape In ActiveDocument.InlineShapes
xShape.Height = Split(xPicSize, “,”)(0)
xShape.Width = Split(xPicSize, “,”)(1)
Next xShape
End Sub
  1. Press F5 to run the code. A Browse window will appear; select the folder containing the images you want to insert.
  2. Click OK, and a prompt will appear asking if you want to resize all pictures.
  3. Click Yes and enter the height and width of the pictures separated by a comma in the text box.
  4.  How to insert multiple pictures with same size in Word document

    How to insert multiple pictures with same size in Word document

    Click OK, and all the inserted images will be resized to the specified dimensions.

Note: The unit of measurement is points in the VBA code.

Now you have successfully inserted multiple images with the same size into your Word document.

We will be happy to hear your thoughts

Leave a reply

Gotkey.net
Logo
Compare items
  • Total (0)
Compare
0
Shopping cart