Gå til hovedindhold

Hvordan finder man og erstatter flere ord på samme tid i et Word-dokument?

Word giver en Find og erstat funktion for at finde alle forekomster af et ord eller en sætning og erstatte dem med et nyt ord på samme tid. Men hvis du vil finde og erstatte forskellige ord på samme tid, kan denne indbyggingsfunktion ikke hjælpe. I denne artikel taler vi om en VBA-metode til at finde og erstatte flere forskellige ord på samme tid i Word-dokument.

Find og erstat flere ord på samme tid i Word med VBA-kode
Find og udskift let flere ord på samme tid i Word med en fantastisk funktion


Find og erstat flere ord på samme tid i Word med VBA-kode

Gør som følger for at finde og erstatte flere ord på samme tid i et Word-dokument.

1. Åbn det Word-dokument, du vil finde, og udskift flere ord på samme tid, og tryk derefter på andre + F11 nøgler til at åbne Microsoft Visual Basic til applikationer vindue.

2. i Microsoft Visual Basic til applikationer vindue, skal du klikke på indsatte > Modul. Kopier derefter under VBA-koden i modulvinduet.

VBA-kode: Find og erstat flere ord på samme tid i Word

Sub FindAndReplaceMultiItems()
'Update by ExtendOffice 2018/10/25
    Dim xFind As String
    Dim xReplace As String
    Dim xFindArr, xReplaceArr
    Dim I As Long
    Application.ScreenUpdating = False
    xFind = InputBox("Enter items to be found here,seperated by comma: ", "Kutools for Word")
    xReplace = InputBox("Enter new items here, seperated by comma: ", "Kutools for Word")
    xFindArr = Split(xFind, ",")
    xReplaceArr = Split(xReplace, ",")
    If UBound(xFindArr) <> UBound(xReplaceArr) Then
        MsgBox "Find and replace characters must be equal.", vbInformation, "Kutools for Word"
        Exit Sub
    End If
    For I = 0 To UBound(xFindArr)
        Selection.HomeKey Unit:=wdStory
        With Selection.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .Text = xFindArr(I)
            .Replacement.Text = xReplaceArr(I)
            .Format = False
            .MatchWholeWord = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    Next
    Application.ScreenUpdating = True
End Sub

3. Tryk på F5 nøgle for at køre koden.

4. I den første Kutools for Word dialogboksen, skal du indtaste de flere ord, du finder, og erstatte i tekstboksen, og adskille dem med komma, og klik derefter på OK knap. Se skærmbillede:

5. I det andet Kutools for Word dialogboksen, skal du indtaste de nye ord, du vil erstatte med (disse ord skal også adskilles med kommaer), og klik derefter på OK .

Bemærk: I dette tilfælde alle "KTE" i dette dokument vil blive erstattet med "Ny", "KTO" "KTW" vil blive erstattet med "Prøve" "Afslut". Skift dem til dine behov.


Find og udskift let flere ord på samme tid i Word med en fantastisk funktion

Batch Find og erstat træk ved Kutools for Word kan hjælpe med let at finde og erstatte forskellige tekster i et dokument eller på tværs af flere dokumenter på samme tid.

Inden du anvender denne funktion, skal du tage minutter til download og installer det først.

1. Start Microsoft Word-applikationen, klik på Kutools Plus > Batch Find og erstat.

2. i Batch Find og erstat vindue, skal du konfigurere som følger.

  • 2.1 klik på knap> Tilføj fil or Tilføj mappe for at tilføje et eller flere dokumenter, hvor du finder og erstatter flere ord.
  • 2.2 Klik på Tilføj række knap for at indsætte find og erstat felter. Hvis du vil finde og erstatte tre forskellige tekster på samme tid, skal du oprette tre rækker.
  • 2.3 I hver række skal du indtaste de eksisterende ord, du vil erstatte med en ny i Finde kolonne, og indtast derefter de nye ord i udskifte kolonne.
  • 2.4 Specificer Søgetype for hver række.
  • 2.5 I Finde ind i kolonnen, vælg hvor du vil finde og erstatte. Det omfatter Hoveddokument, Header Sidefod i dette afsnit. Du kan vælge en af ​​dem, to af dem eller alle ud fra dine behov.
  • 2.6. Klik på udskifte for at starte operationen. Se skærmbillede:

Derefter erstattes de specifikke ord i valgte dokumenter på samme tid.

Tip: Du kan fremhæve resultatet med baggrundsfarve ved at angive en bestemt farve i Fremhæv kolonne for en række.

  Hvis du vil have en gratis prøveperiode (60 dage) af dette værktøj, klik for at downloade det, og gå derefter til at anvende handlingen i henhold til ovenstående trin.

Bedste kontorproduktivitetsværktøjer

Kutools for Word - Forøg din Word-oplevelse med Over 100 Bemærkelsesværdige funktioner!

Dyk ned i de fremhævede funktioner nedenfor eller klik her for at udforske den fulde kraft af Kutools for Word.

📘 Dokumentbeherskelse: Opdelt sider  /  Flet dokumenter  /  Eksporter udvalg i forskellige formater (PDF/TXT/DOC/XLSX)  /  Batch Konverter til PDF  /  Eksporter sider som billeder  /  Udskriv flere filer på én gang ...

Indholdsredigering: Batch Find og erstat på tværs af flere filer   /  Ændr størrelse på alle billeder   /  Transponer tabelrækker og kolonner  /  Konverter tabel til tekst ...

🧹 Ubesværet rengøringFej væk Ekstra pladser  /  Afsnit bryder  /   Alle overskrifter  /  Tekstbokse  /  Hyperlinks  /  For flere fjernelsesværktøjer, gå til vores Fjerngruppe

Kreative indlæg: indsatte Tusind adskillere  /  Afkrydsningsfelter  /  Radio knapper  /  QR kode  /  Stregkode  /  Diagonal linjebord  /  Ligningstekst  /  Billede Caption  /  Tabeltekst  /  Flere billeder  /  Opdag mere i vores Indsæt-gruppe

???? Præcisionsvalg: Find bestemte sider  /  tabeller  /  former  /  overskrifter  /  Naviger nemt ved hjælp af vores udvalgte gruppe

Stjerneforbedringer: Naviger hurtigt til ethvert sted  /  automatisk indsæt gentagende tekst  /  skifte problemfrit mellem dokumentvinduer  /  11 Konverteringsværktøjer ...

Transformer dine Word-opgaver med Kutools. 👉 Download med 30-dages prøveversion nu 🚀.

Læs mere       Gratis download      Køb
 
Comments (21)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Chào bạn, có cách nào thay thế RẤT NHIỀU cụm từ bằng RẤT NHIỀU cụm từ khác (nhập từng cụm từ rất mất thời gian) bằng cách m lập một file trong đó có 2 cột, 1 cột là cụm từ nguồn và cột 2 là cụm từ đích được không? rất cám ơn bạn.
This comment was minimized by the moderator on the site
Hi Nguyễn Phúc Lâm,
I recommand you apply the Batch Find and Replace feature of Kutools for Word (the second method in this post) to solve this problem.
In the Find and Replace dialog box, after creating the two columns you need, you can save the current settings as a scenaria for future use.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/find_and_replace.png
This comment was minimized by the moderator on the site
Cám ơn Crystal, cách này có thể áp dụng với một số lượng nhỏ các cụm từ, nếu với số lượng các cụm từ lớn (hơn 1000, hơn 10000.. cụm từ) thì rất khó để có thể nhập thủ công. Vậy có cách nào khác không bạn? Cám ơn bạn đã trả lời
This comment was minimized by the moderator on the site
Hi Nguyễn Phúc Lâm,
Temporarily unable to deal with this problem with VBA code as it is a bit complex. This feature will be considered for upgrade in the next release. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
Thanks for the project, Could you make it the way we can also replace letters in words. For example if i want to change Dollar as DoLLar it does not function.
This comment was minimized by the moderator on the site
In the first instruction (Find And Replace Multiple Words At The Same Time In Word With VBA Code), it does not find instances where the word to be replaced falls in the middle of a word (For example, .com following a website name). Can this be modified to do so?
This comment was minimized by the moderator on the site
What if I'm trying to replace commas?
This comment was minimized by the moderator on the site
The VBA code can't help to replace commas. You can apply Kutools to achieve.
This comment was minimized by the moderator on the site
After hitting Replace it just goes to Preview and doesn't do anything further.
This comment was minimized by the moderator on the site
Hi Ajs,All required words have been successfully replaced at once after hitting the Replace button. It goes to the Preview tab to help you know how many words have been successfully replaced. After that, close the dialog box.
This comment was minimized by the moderator on the site
Hi! First, congratulations for your work: this macro is very useful and interesting! I would like, neverthless, you help me with one thing. I am a proofreader and would like the replacements would highlithed in green or red color. How can I do this? Is there a code line I could use?
This comment was minimized by the moderator on the site
Hi, The Batch Find and Replace feature of Kutools for Word can perfectly solve your problem, you can have a try.
This comment was minimized by the moderator on the site
Hi how can this macro be revised to take more key words? I have about 170 words that I wold like to find and replace
This comment was minimized by the moderator on the site
Hi JM,
After running the code, a Kutools for Excel dialog box will pop up, please enter the keywords you will find and separate them with commas.
This comment was minimized by the moderator on the site
How to find and select multiple words at the same time
This comment was minimized by the moderator on the site
Hi,
After running the code, a Kutools for Excel dialog box will pop up, please enter the keywords you will find and separate them with commas.
This comment was minimized by the moderator on the site
Hi, This works well with English Words. Now I am doing a document where I translate English to Gujarati. So, when I apply this, (Find English Words) and (Replace with Gujarati words), it does change but it appears like "???". Doesn't show the Gujarati word but just question marks? Any further help? Please.
This comment was minimized by the moderator on the site
Hello Shailesh, facing the same issue. Did you find a solution to it. Am also trying to figure out how to change from Chinese to English.
This comment was minimized by the moderator on the site
Any way to make this case sensitive?
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