How to insert multiple pictures with filename in a Word document?
In a Word document, you can quickly insert multiple pictures at once using the Insert function. However, there may be times when you need to include the file path and filenames as captions when inserting the pictures. This can be particularly useful for documentation, reports, or presentations where referencing the image source is important.
In this tutorial, we will guide you through the steps to efficiently insert multiple pictures along with their file paths and filenames as captions in a Word document, helping you manage your images more effectively.
Insert multiple pictures with filename using a VBA code
Insert multiple pictures with filename using Kutools for Word
Insert multiple pictures with filename by using VBA code
The following VBA code can help you to insert the file path and name as caption when inserting the images, please do as this:
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. And then, click Insert > Module, copy and paste below code into the opened blank module:
VBA code: Insert multiple pictures with filename:
Sub PicWithCaption()
Dim xFileDialog As FileDialog
Dim xPath, xFile As Variant
On Error Resume Next
Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
If xFileDialog.Show = -1 Then
xPath = xFileDialog.SelectedItems.Item(1)
If xPath <> "" Then
xFile = Dir(xPath & "\*.*")
Do While xFile <> ""
If UCase(Right(xFile, 3)) = "PNG" Or _
UCase(Right(xFile, 3)) = "TIF" Or _
UCase(Right(xFile, 3)) = "JPG" Or _
UCase(Right(xFile, 3)) = "GIF" Or _
UCase(Right(xFile, 3)) = "BMP" Then
With Selection
.InlineShapes.AddPicture xPath & "\" & xFile, False, True
.InsertAfter vbCrLf
.MoveDown wdLine
.Text = xPath & "\" & xFile & Chr(10)
.MoveDown wdLine
End With
End If
xFile = Dir()
Loop
End If
End If
End Sub
3. Then press F5 key to run this code, a Browse window is displayed, please select the folder that contains the images you want to insert, see screenshot:
4. Then click OK button, all the images in the selected folder have been inserted into the Word document, and the file path and name is inserted as caption we well, see screenshot:
Insert multiple pictures with filename by using Kutools for Word
If you have Kutools for Word, with its Images feature, you can quickly insert multiple pictures with file path and name into the Word document immediately.
After installing Kutools for Word, please do as this:
1. Click Kutools > Images, see screenshot:
2. In the popped out Insert Pictures dialog box, please do the below operations:
- (1) Click Add Files or Add Folder button to select the images that you want to insert;
- (2) Then check Insert file path of each picture as caption option at the left bottom of the dialog box;
- (3) And then click Insert button.
3. After inserting the images, you will see each picture’s file path and name is inserted as well, see screenshot:
Best Office Productivity Tools
Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!
🤖 Kutools AI Assistant: Transform your writing with AI - Generate Content / Rewrite Text / Summarize Documents / Get Quick Answers, all within Word
📘 Document Mastery: Split Pages / Merge Documents / Export Selection in Various Formats (PDF/TXT/DOC/HTML...) / Batch Convert to PDF / Export Pages as Images / Print Multiple Files at once...
✏ Contents Editing: Batch Find and Replace across Multiple Files / Resize All Pictures / Transpose Table Rows and Columns / Convert Table to Text...
🧹 Effortless Clean: Sweap away Extra Spaces / Section Breaks / All Headers / Text Boxes / Hyperlinks / For more removing tools, head to the Remove group...
➕ Creative Inserts: Insert Thousand Separators / Check Boxes / Radio Buttons / QR Code / Barcode / Diagonal Line Table / Equation Caption / Image Caption / Table Caption / Multiple Pictures / Discover more in the Insert group...
🔍 Precision Selections: Pinpoint Specific Pages / Tables / Shapes / Heading Paragraphs / Enhance navigation with more Select features...
⭐ Star Enhancements: Navigate to Any Location / Auto-Insert Repetitive Text / Toggle Between Document Windows / 11 Conversion Tools...
![Kutools and Kutools Plus tabs on the Word Ribbon](http://cdn.extendoffice.com/images/stories/ktw12-bar.png)
![PATAN](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![Rachel Jackson](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![Rizza](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![skyyang](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![JM](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![_adelie01](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![James](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)