Loncat ke daftar isi utama

Bagaimana cara menyisipkan banyak gambar dengan nama file di dokumen Word?

Pengarang: Xiaoyang Terakhir Dimodifikasi: 2023-01-16

Di dokumen Word, Anda dapat dengan cepat menyisipkan beberapa gambar sekaligus dengan menggunakan fungsi Sisipkan. Namun, terkadang, Anda perlu memasukkan jalur file dan nama sebagai keterangan saat menyisipkan gambar. Bagaimana Anda bisa menangani tugas ini di file Word?

Masukkan banyak gambar dengan nama file menggunakan kode VBA

Masukkan beberapa gambar dengan nama file menggunakan Kutools for Word


Masukkan banyak gambar dengan nama file menggunakan kode VBA

Kode VBA berikut dapat membantu Anda memasukkan jalur file dan nama sebagai keterangan saat memasukkan gambar, lakukan seperti ini:

1. Tahan ALT + F11 kunci untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Dan kemudian, klik Menyisipkan > Modul, salin dan tempel kode di bawah ini ke dalam modul kosong yang dibuka:

Kode VBA: Masukkan banyak gambar dengan nama file:

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. Lalu tekan F5 kunci untuk menjalankan kode ini, jendela Browse ditampilkan, pilih folder yang berisi gambar yang ingin Anda masukkan, lihat tangkapan layar:

doc memasukkan gambar dengan nama file 1

4. Lalu klik OK tombol, semua gambar di folder yang dipilih telah dimasukkan ke dalam dokumen Word, dan jalur file dan nama dimasukkan sebagai keterangan kami dengan baik, lihat tangkapan layar:

doc memasukkan gambar dengan nama file 2


Masukkan beberapa gambar dengan nama file menggunakan Kutools for Word

Jika Anda memiliki Kutools for Word, Dengan yang Images fitur, Anda dapat dengan cepat memasukkan beberapa gambar dengan jalur file dan nama ke dokumen Word dengan segera.

Kutools for Word : dengan lebih dari 100 add-in Word yang praktis, gratis untuk dicoba tanpa batasan dalam 60 hari. 

Setelah menginstal Kutools for Word, lakukan seperti ini:

1. Klik Kutools > Images, lihat tangkapan layar:

doc memasukkan gambar dengan nama file 3

2. Di muncul keluar Sisipkan Gambar kotak dialog, lakukan operasi di bawah ini:

  • (1.) Klik Tambahkan File or Tambah Folder tombol untuk memilih gambar yang ingin Anda sisipkan;
  • (2.) Kemudian periksa Sisipkan jalur file dari setiap gambar sebagai keterangan opsi di kiri bawah kotak dialog;
  • (3.) Lalu klik Menyisipkan .

doc memasukkan gambar dengan nama file 4

3. Setelah memasukkan gambar, Anda akan melihat jalur file setiap gambar dan nama dimasukkan juga, lihat tangkapan layar:

doc memasukkan gambar dengan nama file 5

Klik untuk mengunduh Kutools for Word dan uji coba gratis sekarang!

Alat Produktivitas Kantor Terbaik

Kutools for Word - Tingkatkan Pengalaman Kata Anda dengan Over 100 Fitur Luar Biasa!

🤖 Asisten AI Kutools: Ubah tulisan Anda dengan AI - Hasilkan Konten  /  Menulis Ulang Teks  /  Meringkas Dokumen  /  Menanyakan Informasi berdasarkan Dokumen, semuanya dalam Word

📘 Penguasaan Dokumen: Halaman Terpisah  /  Gabungkan Dokumen  /  Ekspor Pilihan dalam Berbagai Format (PDF/TXT/DOC/HTML...)  /  Konversi Batch ke PDF  /  Ekspor Halaman sebagai Gambar  /  Cetak Banyak File sekaligus...

Pengeditan Isi: Temukan dan Ganti Batch di Banyak File  /  Ubah Ukuran Semua Gambar  /  Ubah Urutan Baris dan Kolom Tabel  /  Ubah Tabel menjadi Teks...

🧹 Bersih dengan Mudah: Menyapu Spasi Ekstra  /  Bagian Istirahat  /  Semua Header  /  Teks box  /  Hyperlink  / Untuk alat penghapus lainnya, kunjungi Hapus grup...

Sisipan Kreatif: Memasukkan Seribu Pemisah  /  Kotak Centang  /  Tombol Radio  /  Kode QR  /  barcode  /  Tabel Garis Diagonal  /  Keterangan Persamaan  /  Keterangan gambar  /  Keterangan Tabel  /  Banyak Gambar  / Temukan lebih lanjut di Sisipkan grup...

🔍 Pilihan Presisi: Tepat Halaman Tertentu  /  Meja  /  bentuk  /  Paragraf Judul  / Tingkatkan navigasi dengan lebih Pilih fitur...

Peningkatan Bintang: Navigasi ke Lokasi Mana Pun  /  Sisipkan Otomatis Teks Berulang  /  Beralih Antar Jendela Dokumen  /  11 Alat Konversi...

👉 Ingin mencoba fitur-fitur tersebut? Kutools for Word menawarkan a Uji coba gratis 60-hari, tanpa batasan! 🚀
 
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