Ga naar hoofdinhoud

Hoe voeg ik meerdere afbeeldingen met bestandsnaam in Word-document in?

In Word-document kunt u snel meerdere afbeeldingen tegelijk invoegen met behulp van de functie Invoegen. Maar soms moet u het bestandspad en de namen als bijschrift invoegen bij het invoegen van de afbeeldingen. Hoe zou u deze taak in Word-bestand kunnen aanpakken?

Voeg meerdere afbeeldingen met bestandsnaam in met behulp van VBA-code

Voeg meerdere afbeeldingen met bestandsnaam in met Kutools voor Word


Voeg meerdere afbeeldingen met bestandsnaam in met behulp van VBA-code

De volgende VBA-code kan u helpen bij het invoegen van het bestandspad en de naam als bijschrift bij het invoegen van de afbeeldingen, doe dit als volgt:

1. Houd de ALT + F11 toetsen om de te openen Microsoft Visual Basic voor toepassingen venster.

2. En klik dan Invoegen > Module, kopieer en plak onderstaande code in de geopende lege module:

VBA-code: voeg meerdere afbeeldingen in met bestandsnaam:

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. Druk vervolgens op F5 toets om deze code uit te voeren, een bladervenster wordt weergegeven, selecteer de map met de afbeeldingen die u wilt invoegen, zie screenshot:

doc afbeeldingen invoegen met bestandsnaam 1

4. Dan klikken OK knop, alle afbeeldingen in de geselecteerde map zijn ingevoegd in het Word-document, en het bestandspad en de naam zijn ingevoegd als bijschrift, zie screenshot:

doc afbeeldingen invoegen met bestandsnaam 2


Voeg meerdere afbeeldingen met bestandsnaam in met Kutools voor Word

Als je Kutools for Word, Met Afbeeldingen functie, kunt u snel meerdere afbeeldingen met bestandspad en naam onmiddellijk in het Word-document invoegen.

Kutools for Word : met meer dan 100 handige Word-invoegtoepassingen, gratis te proberen zonder beperking in 60 dagen. 

Na het installeren van Kutools for Word, doe dit als volgt:

1. Klik Kutools > Afbeeldingen, zie screenshot:

doc afbeeldingen invoegen met bestandsnaam 3

2. In de pop-out Afbeeldingen invoegen dialoogvenster, voer de onderstaande bewerkingen uit:

  • (1.) Klik Bestanden toevoegen or Map toevoegen knop om de afbeeldingen te selecteren die u wilt invoegen;
  • (2.) Controleer dan Voeg het bestandspad van elke foto in als bijschrift optie linksonder in het dialoogvenster;
  • (3.) En klik dan Invoegen knop.

doc afbeeldingen invoegen met bestandsnaam 4

3. Nadat u de afbeeldingen hebt ingevoegd, ziet u het bestandspad van elke afbeelding en wordt de naam ook ingevoegd, zie screenshot:

doc afbeeldingen invoegen met bestandsnaam 5

Klik om Kutools voor Word en nu gratis uit te proberen!

Beste Office-productiviteitstools

Kutools for Word - Verbeter uw woordervaring met Over 100 Opmerkelijke kenmerken!

🤖 Kutools AI-assistent: Transformeer uw schrijven met AI - Inhoud genereren  /  Herschrijf tekst  /  Documenten samenvatten  /  Informeer voor informatie gebaseerd op document, allemaal binnen Word

📘 Documentbeheersing: Pagina's splitsen  /  Voeg documenten samen  /  Selectie exporteren in verschillende formaten (PDF/TXT/DOC/HTML...)  /  Batchconversie naar PDF  /  Pagina's exporteren als afbeeldingen  /  Meerdere bestanden tegelijk afdrukken...

Inhoud bewerken: Batch zoeken en vervangen over meerdere bestanden  /  Formaat van alle afbeeldingen wijzigen  /  Tabelrijen en -kolommen transponeren  /  Converteer tabel naar tekst...

🧹 Moeiteloos schoon: Veeg weg Extra ruimtes  /  Sectie-onderbrekingen  /  Alle koppen  /  Tekstvakken  /  hyperlinks  / Ga voor meer verwijdergereedschappen naar onze Groep verwijderen...

Creatieve invoegingen: Invoegen Duizend scheidingstekens  /  Vink vakjes aan  /  Radio knoppen  /  QR Code  /  Barcode  /  Diagonale lijntabel  /  Vergelijking bijschrift  /  Bijschrift bij afbeelding  /  Tabel titel  /  Meerdere afbeeldingen  / Ontdek meer in de Groep invoegen...

???? Precisieselecties: Vaststellen specifieke pagina's  /  tafels  /  vormen  /  kop paragrafen  / Verbeter de navigatie met meer Selecteer functies...

Sterverbeteringen: Navigeer snel naar elke locatie  /  automatisch herhaalde tekst invoegen  /  naadloos schakelen tussen documentvensters  /  11 Conversiehulpmiddelen...

👉 Wil je deze functies proberen? Kutools voor Word biedt een Gratis proefperiode van 60-dag, zonder beperkingen! 🚀
 
Comments (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
VBA CODE IS VERY USEFULLY MY DATA VALIDATE IMAGES SHARING.
This comment was minimized by the moderator on the site
How can I decrease the overall size of the photo so there are multiple per page?
This comment was minimized by the moderator on the site
Is there a way to insert each picture and file name per page? Sometimes if one picture is too big the file name will then go to the next page or if picture is too small the next picture will be together in one page instead on the next page
This comment was minimized by the moderator on the site
Hello, Rizza,
To insert each picture and file name per page, please apply the following vba code:
Sub PicWithCaption()
    Dim xFileDialog As FileDialog
    Dim xPath As String, xFile As String
    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
                    
                    ' Add the picture
                    Selection.InlineShapes.AddPicture xPath & "\" & xFile, False, True
                    Selection.TypeParagraph
                    
                    ' Add the file path below the picture
                    Selection.TypeText xPath & "\" & xFile
                    Selection.TypeParagraph
                    
                    ' Move to the next page
                    Selection.InsertBreak Type:=wdPageBreak
                End If
                xFile = Dir()
            Loop
        End If
    End If
End Sub


Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
A problem occurs when the file name to be added exceeds 10.

pic1
pic10
pic11
pic12
pic2
pic3
pic4
pic5...
This comment was minimized by the moderator on the site
change the file name to 01, 02, 03 and it will work
This comment was minimized by the moderator on the site
Wow this is great! I only needed the file name, so I deleted "xPath & "\" &" from the .Text line and that worked perfectly. Thanks for this!
This comment was minimized by the moderator on the site
Which line of code would you change and how to have the file path written before the picture, aka the caption (filename) is above rather than below.
This comment was minimized by the moderator on the site
With Selection
.Text = xFile
.InlineShapes.AddPicture xPath & "\" & xFile, False, True
.InsertAfter vbCrLf
.MoveDown wdLine

End With
This comment was minimized by the moderator on the site
Have to add this .MoveDown wdLine after .Text=xFile
This comment was minimized by the moderator on the site
buenas noches amigo me ha servido mucho su información sinembargo me surge una duda cree que es posible incertar imagenes en word de la misma manera pero dentro de celdas incertadas?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations