Loncat ke daftar isi utama

Bagaimana cara mencari dan mengganti beberapa file di Word?

Jika Anda memiliki beberapa lusin file kata yang berisi konten yang sama (seperti Header, footer, beberapa kata atau angka khusus), dan Anda perlu mengganti konten yang sama di seluruh dokumen tersebut di Word. Bagaimana lebih mudah bagi Anda untuk menyelesaikannya dengan cepat? Tentunya, Anda dapat membuka file tersebut satu per satu untuk mengganti konten yang sama, tetapi akan memakan waktu dan merepotkan. Tutorial ini akan menunjukkan kepada Anda cara rumit untuk mengganti konten yang sama dalam beberapa dokumen di Word sekaligus.

Temukan dan ganti teks di beberapa dokumen kata secara bersamaan dengan kode VBA
Temukan dan ganti teks yang berbeda dengan mudah di beberapa dokumen secara bersamaan dengan Kutools for Word


Temukan dan ganti teks di beberapa dokumen kata secara bersamaan dengan kode VBA

1. tekan lain + F11 untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Dalam Microsoft Visual Basic untuk Aplikasi window, klik MenyisipkanModul, lalu salin kode VBA berikut ke jendela Modul.

Kode VBA: Mencari dan mengganti konten yang sama di beberapa dokumen sekaligus

Sub CommandButton1_Click()
'Updated by Extendoffice 20180625
Dim xFileDialog As FileDialog, GetStr(1 To 100) As String '100 files is the maximum applying this code
Dim xFindStr As String
Dim xReplaceStr As String
Dim xDoc As Document
On Error Resume Next
Set xFileDialog = Application.FileDialog(msoFileDialogFilePicker)
With xFileDialog
    .Filters.Clear
    .Filters.Add "All WORD File ", "*.docx", 1
    .AllowMultiSelect = True
    i = 1
    If .Show = -1 Then
        For Each stiSelectedItem In .SelectedItems
            GetStr(i) = stiSelectedItem
            i = i + 1
        Next
        i = i - 1
    End If
    Application.ScreenUpdating = False
    xFindStr = InputBox("Find what:", "Kutools for Word", xFindStr)
    xReplaceStr = InputBox("Replace with:", "Kutools for Word", xReplaceStr)
    For j = 1 To i Step 1
        Set xDoc = Documents.Open(FileName:=GetStr(j), Visible:=True)
        Windows(GetStr(j)).Activate
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = xFindStr  'Find What
            .Replacement.Text = xReplaceStr  'Replace With
            .Forward = True
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchByte = True
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        Application.Run macroname:="NEWMACROS"
        ActiveDocument.Save
        ActiveWindow.Close
    Next
    Application.ScreenUpdating = True
End With
MsgBox "Operation end, please view", vbInformation
End Sub

3. tekan F5 kunci untuk menjalankan kode.

4. Dalam pembukaan Browse jendela, temukan dan pilih dokumen yang akan Anda temukan dan ganti teks di dalamnya, lalu klik OK tombol. Lihat tangkapan layar:

5. Yang pertama Kutools for Word kotak dialog, masukkan teks yang akan Anda temukan di seluruh dokumen ke dalam Temukan apa kotak, dan kemudian klik OK .

6. Di kedua Kutools for Word kotak dialog, masukkan teks yang akan Anda ganti, dan klik OK .

8. Klik OK tombol berikutnya Microsoft Word kotak dialog untuk menyelesaikan pencarian dan penggantian.

Dalam hal ini, semua kata "Word" dalam dokumen yang dipilih diganti dengan "Excel" secara bersamaan.


Temukan dan ganti teks yang berbeda dengan mudah di beberapa dokumen secara bersamaan dengan Kutools for Word

Di sini sangat merekomendasikan Temukan dan Ganti Batch fitur dari Kutools for Word. Dengan fitur ini, Anda dapat dengan mudah menemukan dan mengganti teks yang berbeda di beberapa dokumen Word secara bersamaan. Mari kita lihat cara menerapkan fitur ini untuk menemukan dan mengganti teks di seluruh dokumen.

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

1. Silakan klik Kutools Ditambah > Temukan dan Ganti Batch untuk mengaktifkan fitur.

2. Dalam Temukan dan Ganti Batch kotak dialog, konfigurasikan sebagai berikut.

  • 2.1) Klik Tambahkan Baris tombol di bawah Cari dan Ganti Tab;
  • 2.2) Di bidang baris yang dibuat:
A. Masukkan teks yang akan Anda temukan ke dalam kotak teks di Menemukan kolom
B. Masukkan teks yang akan Anda ganti ke dalam kotak teks di menggantikan kolom;
C. Tentukan jenis pencarian, di mana menemukan teks dan warna untuk menyorot teks yang Anda butuhkan. Dalam hal ini, saya pilih Pencocokan kata lengkap, Dokumen utama dan warna tertentu dari Jenis Pencarian, Temukan di dan Menyoroti kolom;
  • 2.3) Ulangi langkah 2.1 dan 2.2 untuk menambahkan lebih banyak teks yang akan Anda temukan dan ganti;
  • 2.4) Klik  tombol di Jenis File bagian untuk menambahkan dokumen Word di mana Anda akan menemukan dan mengganti teks;
  • 2.5) Klik menggantikan or Menemukan tombol. Lihat tangkapan layar:

Catatan:
1. Jika Anda mengklik Menemukan tombol, semua hasil pencarian akan ditampilkan di bawah Pratinjau Hasil tab. Setelah melihat hasilnya, jika Anda ingin mengganti semua teks, silakan klik Cari dan Ganti tab. Jika tidak, tutup dialog.

2. Jika Anda mengklik menggantikan , semua teks yang ditentukan akan segera diganti dengan yang baru, dan hasilnya juga akan ditampilkan di bawah Pratinjau Hasil Tab.

3. Jika Anda menentukan warna sorotan pada langkah 2, semua teks yang diganti akan disorot dengan warna yang ditentukan, dan Anda dapat dengan mudah menemukannya sekilas di dokumen.

3. Tutup Temukan dan Ganti Batch kotak dialog

Untuk informasi lebih lanjut tentang fitur ini, silakan klik disini....

Jika Anda ingin mencoba utilitas ini secara gratis, buka unduh perangkat lunak gratis pertama, lalu lanjutkan untuk menerapkan operasi sesuai langkah di atas.

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 kami 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  /  tabel  /  bentuk  /  paragraf judul  / Tingkatkan navigasi dengan lebih Pilih fitur...

Peningkatan Bintang: Navigasi dengan cepat ke lokasi mana pun  /  menyisipkan teks berulang secara otomatis  /  beralih antar jendela dokumen dengan mulus  /  11 Alat Konversi...

👉 Ingin mencoba fitur-fitur tersebut? Kutools for Word menawarkan a Uji coba gratis 60-hari, tanpa batasan! 🚀
 
Comments (71)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Congrats!!! Your VBA code saves a lot of time. 5*
Rated 5 out of 5
This comment was minimized by the moderator on the site
thanks for -How To Search And Replace Across Multiple Files In Word?

what about from out side (by folder) ?

thanks gain
This comment was minimized by the moderator on the site
This is a great explanation.  Is there a way to change settings, e.g. page size, simultaneously? 
This comment was minimized by the moderator on the site
After pressing F5, I get the following error" "Compile error: User-defined type not defined." Can someone help?
This comment was minimized by the moderator on the site
Hi Monique,Please check if the Microsoft Office Object Library is enabled as shown in the screenshot below.
This comment was minimized by the moderator on the site
This is SUCH a time saving solution. THANK YOU!
One thing that may make it even better, is adding support for subdirectories. (That is: Files in multiple subdirectories)
I am an absolute newbie in this, and don't know the syntax, the parameter, or where to add that.

Could somebody help?
This comment was minimized by the moderator on the site
I need to replace text in multiple Word files and have the replaced text highlighted. Is there a way to do this?
This comment was minimized by the moderator on the site
Hi Daphne,
Why not try the Batch Find and Replace feature of Kutools for Word? It can solve this issue with ease.
This comment was minimized by the moderator on the site
this was a lifesaver thank you so much
This comment was minimized by the moderator on the site
Is it possible to replace in the headers of the word doc?
This comment was minimized by the moderator on the site
Hi Tiago,
Please apply the below VBA code to include the content of headers and footers when finding and replacing texts in multiple documents at once.

Sub CommandButton1_Click()
'Updated by Extendoffice 20180625
Dim xFileDialog As FileDialog, GetStr(1 To 100) As String '100 files is the maximum applying this code
Dim xFindStr As String
Dim xReplaceStr As String
Dim xDoc As Document
On Error Resume Next
Set xFileDialog = Application.FileDialog(msoFileDialogFilePicker)
With xFileDialog
.Filters.Clear
.Filters.Add "All WORD File ", "*.docx", 1
.AllowMultiSelect = True
i = 1
If .Show = -1 Then
For Each stiSelectedItem In .SelectedItems
GetStr(i) = stiSelectedItem
i = i + 1
Next
i = i - 1
End If
Application.ScreenUpdating = False
xFindStr = InputBox("Find what:", "Kutools for Word", xFindStr)
xReplaceStr = InputBox("Replace with:", "Kutools for Word", xReplaceStr)
For j = 1 To i Step 1
Set xDoc = Documents.Open(FileName:=GetStr(j), Visible:=True)
Windows(GetStr(j)).Activate
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = xFindStr 'Find What
.Replacement.Text = xReplaceStr 'Replace With
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Application.Run macroname:="NEWMACROS"
If MsgBox("Do you want to replace texts in headers and footers too? ", vbYesNo, "Kutools for Word") = vbYes Then
ActiveWindow.View.SplitSpecial = wdPanePrimaryFooter
Selection.Find.Execute Replace:=wdReplaceAll
Application.Run macroname:="NEWMACROS"
ActiveWindow.View.SplitSpecial = wdPanePrimaryHeader
Selection.Find.Execute Replace:=wdReplaceAll
Application.Run macroname:="NEWMACROS"
End If
ActiveDocument.Save
ActiveWindow.Close
Next
Application.ScreenUpdating = True
End With
MsgBox "Operation end, please view", vbInformation
End Sub
This comment was minimized by the moderator on the site
Is that possible to replace in the header of the word doc?
This comment was minimized by the moderator on the site
Thanks for sharing this information with us.
Word search and replace tool
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations