Skip to main content

How to insert multiple pictures with filename in a Word document?

Author Xiaoyang Last modified

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 using VBA code

The following VBA code helps you insert multiple pictures along with their file path and name as captions. Please follow these steps:

  1. Hold down Alt + F11 to open the Microsoft Visual Basic for Applications window.
  2. Click Insert > Module, and paste the following code into the opened module:
    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. Press F5 to run the code. A Browse window will appear where you can select the folder containing the images.
  4. Select a folder to insert pictures from

  5. Click OK, and all images from the selected folder will be inserted into the Word document, with their file path and name included as captions.

    Selected pictures are inserted into the document with filenames


Insert multiple pictures with filename by using Kutools for Word

Using Kutools for Word provides an efficient way to insert multiple pictures along with their file paths and names into a Word document. This feature saves time and ensures accuracy compared to manually adding file details. With its Images feature, you can accomplish this task effortlessly.

Kutools for Word, equipped with AI πŸ€–, offers over 100 handy features to simplify your tasks.

After installing Kutools for Word, follow these steps:

  1. Click Kutools > Multi-Picture.

    Multi-Picture option on the Kutools tab on the ribbon

  2. In the popped-out Insert Pictures dialog box, perform the following operations:
    • Click Add Files or Add Folder to select the images you want to insert.
    • Check the Insert file path of each picture as caption option at the bottom left of the dialog box.
    • Click the Insert button to insert the images at once.

      Insert Pictures dialog box

  3. After inserting the images, each picture's file path and name will be added as a caption.

    Selected pictures are inserted into the document with filenames

Kutools for Word is the ultimate Word add-in that streamlines your work and boosts your document processing skills. Get It Now!

Best Office Productivity Tools

Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!

πŸ€– Kutools AI Features: AI Assistant / Real-Time Assistant / Super Polish (Preserve Format) / Super Translate (Preserve Format) / AI Redaction / AI Proofread...

πŸ“˜ Document Mastery: Split Pages / Merge Documents / Export Selection in Various Formats (PDF/TXT/DOC/HTML...) / Batch Convert to PDF...

✏ 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 / Text Boxes / Hyperlinks / For more removing tools, head to the Remove group...

βž• Creative Inserts: Insert Thousand Separators / Check Boxes / Radio Buttons / QR Code / Barcode / 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...

🌍 Supports 40+ Languages: Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Kutools and Kutools Plus tabs on the Word Ribbon
πŸ‘‰ Want to try these features? Download Kutools for Word now! πŸš€
 

Best Office Productivity Tools

Kutools for Word - 100+ Tools for Word