Ugrás a tartalomra

Hogyan lehet több fájlban keresni és cserélni szóban?

Ha több tucat szófájl van, amelyek ugyanazt a tartalmat tartalmazzák (például Fejléc, lábléc, néhány speciális szó vagy szám), és ugyanazt a tartalmat ki kell cserélnie a Word összes dokumentumában. Hogyan lenne könnyebb gyorsan elkészíteni? Természetesen ezeket a fájlokat egyesével megnyithatja ugyanazon tartalom helyettesítésére, de ez időigényes és problémás lesz. Ez az oktatóanyag trükkös módszert mutat be, amellyel ugyanazt a tartalmat egyszerre több dokumentumban is cserélheti a Word-ben.

Keresse meg és cserélje le egyszerre a többszavas dokumentumok szövegeit VBA kóddal
A Kutools for Word segítségével könnyedén kereshet meg és cserélhet le különböző szövegeket egyszerre több dokumentumban


Keresse meg és cserélje le egyszerre a többszavas dokumentumok szövegeit VBA kóddal

1. nyomja meg más + F11 megnyitni Microsoft Visual Basic for Applications ablak.

2. Ban,-ben Microsoft Visual Basic for Applications ablakban kattintson betétlapModulok, majd másolja a következő VBA kódot a Modul ablakba.

VBA-kód: Ugyanazon tartalom keresése és cseréje több dokumentumban egyszerre

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. megnyomni a F5 gombot a kód futtatásához.

4. A nyílásban Tallózás ablakban keresse meg és válassza ki azokat a dokumentumokat, amelyekben megtalálja és kicseréli a szöveget, majd kattintson a gombra OK gomb. Lásd a képernyőképet:

5. Az elsőben Kutools for Word párbeszédpanelen írja be a dokumentumokban található szöveget a Mit keres jelölőnégyzetet, majd kattintson a gombra OK gombot.

6. A másodikban Kutools for Word párbeszédpanelen írja be a helyettesíteni kívánt szöveget, majd kattintson a gombra OK gombot.

8. Kattintson a OK gombra a következőben Microsoft Word párbeszédpanel a keresés befejezéséhez és cseréjéhez.

Ebben az esetben a kiválasztott dokumentumok összes "Word" szóját egyszerre "Excel" helyettesíti.


A Kutools for Word segítségével könnyedén kereshet meg és cserélhet le különböző szövegeket egyszerre több dokumentumban

Itt nagyon ajánlom a Kötegelt keresés és csere jellemzője Kutools for Word. Ezzel a funkcióval könnyen megtalálhatja és kicserélheti a különböző szövegeket egyszerre több Word dokumentumban. Lássuk, hogyan kell alkalmazni ezt a funkciót a szövegek megkeresésére és cseréjére a dokumentumok között.

Kutools for Word : több mint 100 praktikus Word-bővítménnyel, ingyenesen kipróbálható korlátozás nélkül 60 napok.

1. Kattintson a gombra Kutools Plus > Kötegelt keresés és csere a funkció engedélyezéséhez.

2. Ban,-ben Kötegelt keresés és csere párbeszédpanelt, kérjük, konfigurálja az alábbiak szerint.

  • 2.1) Kattintson a gombra Add Row gombot a Keresés és csere fül;
  • 2.2) A létrehozott sorokban:
A. Írja be a megtalált szöveget a Találjon oszlop
B. Írja be a kicserélendő szöveget a Cserélje oszlop;
C. Adjon meg egy keresési típust, ahol a szöveget megtalálja, és egy színt a szöveg szükség szerinti kiemeléséhez. Ebben az esetben én választom Teljes szó egyezés, Fő dokumentum és egy bizonyos szín a Keresés típusa, Keresse meg és a Kiemel oszlopok;
  • 2.3) Ismételje meg a 2.1 és 2.2 lépéseket további szövegek hozzáadásához, amelyeket megtalálni és pótolni fog;
  • 2.4) Kattintson a gombra  gombot a Fájl típus szakaszban hozzáadhatja azokat a Word dokumentumokat, amelyekben szövegeket talál és cserél;
  • 2.5) Kattintson a gombra Cserélje or Találjon gomb. Lásd a képernyőképet:

Megjegyzések:
1. Ha rákattint a Találjon gombra, az összes találati eredmény megjelenik a Eredmény előnézete fülre. Az eredmények előnézete után, ha az összes szöveget ki akarja cserélni, kattintson a gombra Keresés és csere fülre. Ellenkező esetben zárja be a párbeszédpanelt.

2. Ha rákattint a Cserélje gombra kattintva az összes megadott szöveget azonnal újakra cseréljük, és az eredmények a Eredmény előnézete Tab.

3. Ha a 2. lépésben megadja a kiemelő színeket, akkor az összes kicserélt szöveg kijelölt színnel lesz kiemelve, és könnyedén megtalálhatja őket egy pillanat alatt a dokumentumokban.

3. Csukja be a Kötegelt keresés és csere párbeszédablak

Ha további információt szeretne erről a funkcióról, kérjük kattints ide....

Ha szeretné ingyenesen kipróbálni ezt a segédprogramot, kérjük, látogasson el ide: ingyenesen letölthető a szoftver először, majd lépjen a művelet végrehajtására a fenti lépések szerint.

A legjobb irodai hatékonyságnövelő eszközök

Kutools for Word - Növelje Word-élményét az Over segítségével 100 Figyelemre méltó tulajdonságok!

🤖 Kutools AI asszisztens: Alakítsa át írását mesterséges intelligencia segítségével - Tartalom létrehozása  /  Szöveg átírása  /  Összefoglalja a dokumentumokat  /  Információért érdeklődjön dokumentum alapján, mindezt a Word-en belül

📘 Dokumentummesterség: Felosztott oldalak  /  Dokumentumok egyesítése  /  Kijelölés exportálása különböző formátumokban (PDF/TXT/DOC/HTML...)  /  Kötegelt konvertálás PDF-be  /  Oldalak exportálása képként  /  Nyomtasson több fájlt egyszerre...

Tartalom Szerkesztés: Kötegelt keresés és csere Több fájl között  /  Minden kép átméretezése  /  Transzponálja a táblázat sorait és oszlopait  /  Táblázat konvertálása szöveggé...

🧹 Könnyed tisztítás: Söpörj el Extra helyek  /  Szakaszszünetek  /  Minden fejléc  /  Szövegdobozok  /  Hiperhivatkozások  / További eltávolító eszközökért látogasson el a mi oldalunkra Csoport eltávolítása...

Kreatív betétek: Beszúrás Ezer elválasztó  /  Jelölőnégyzetek  /  Rádió gombok  /  QR-kód  /  Vonalkód  /  Átlós vonal táblázat  /  Egyenletfelirat  /  Képfelirat  /  Táblázat felirata  /  Több kép  / Fedezzen fel többet a Csoport beszúrása...

???? Precíziós kiválasztás: Pontosan konkrét oldalak  /  asztalok  /  formák  /  címsor bekezdései  / A navigáció javítása a következővel: több Jelölje ki a funkciókat...

Star Enhancements: Gyorsan navigáljon bármely helyre  /  ismétlődő szöveg automatikus beszúrása  /  zökkenőmentesen válthat a dokumentumablakok között  /  11 Konverziós eszközök...

???? Ki szeretné próbálni ezeket a funkciókat? A Kutools for Word kínál a 60 napos ingyenes próba, korlátozások nélkül! 🚀
 
Comments (70)
No ratings yet. Be the first to rate!
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
This comment was minimized by the moderator on the site
Works perfectly but is there a similar macro to change text in the header! because this does not work with this version!
thanks
This comment was minimized by the moderator on the site
Hi,
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
Oh yeah! Thank you sooooo much! This is a life-saver!
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