Preskoči na glavno vsebino

Kako iskati in zamenjati več besed hkrati v Wordovem dokumentu?

Word ponuja funkcijo Najdi in zamenjaj, da poišče vse primere besede ali besedne zveze in jih hkrati nadomesti z novo besedo. Če pa želite hkrati iskati in nadomeščati različne besede, vam ta vgrajena funkcija ne more pomagati. V tem članku govorimo o metodi VBA za iskanje in zamenjavo več različnih besed hkrati v Wordovem dokumentu.

Poiščite in zamenjajte več besed hkrati v Wordu s kodo VBA
Preprosto poiščite in zamenjajte več besed hkrati v Wordu z neverjetno funkcijo


Poiščite in zamenjajte več besed hkrati v Wordu s kodo VBA

Za iskanje in zamenjavo več besed hkrati v besedilu Word naredite naslednje.

1. Odprite Wordov dokument, v katerem želite hkrati najti in zamenjati več besed, nato pritisnite druga + F11 tipke za odpiranje Microsoft Visual Basic za aplikacije okno.

2. V Ljubljani Microsoft Visual Basic za aplikacije okno, kliknite Vstavi > Modul. Nato kopirajte spodnjo kodo VBA v okno modula.

Koda VBA: poiščite in zamenjajte več besed hkrati v Wordu

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. Pritisnite F5 tipko za zagon kode.

4. V prvem Kutools za Word v pogovorno okno vnesite več besed, ki jih boste našli in zamenjali, v besedilno polje in jih ločite z vejico, nato kliknite OK . Oglejte si posnetek zaslona:

5. V drugem Kutools za Word v pogovorno okno vnesite nove besede, ki jih boste zamenjali (te besede je treba ločiti tudi z vejicami), in kliknite na OK gumb.

Opomba: V tem primeru vsi "KTE" v tem dokumentu bo nadomeščen z "Novo", in "KTO" in "KTW" bo nadomeščen z "Test" in "Končaj". Prosimo, spremenite jih glede na vaše potrebe.


Preprosto poiščite in zamenjajte več besed hkrati v Wordu z neverjetno funkcijo

O Serijsko iskanje in zamenjava značilnost Kutools za Word lahko pomaga pri lažjem iskanju in zamenjavi različnih besedil v dokumentu ali v več dokumentih hkrati.

Preden uporabite to funkcijo, si vzemite nekaj minut najprej ga prenesite in namestite.

1. Zaženite aplikacijo Microsoft Word, kliknite Kutools Plus > Serijsko iskanje in zamenjava.

2. V Ljubljani Serijsko iskanje in zamenjava okno, nastavite na naslednji način.

  • 2.1 kliknite gumb> Dodaj datoteko or dodaj mapo da dodate enega ali več dokumentov, v katerih boste našli in zamenjali več besed.
  • 2.2 Kliknite na Dodaj vrstico gumb, da vstavite polja za iskanje in zamenjavo. Če želite hkrati najti in zamenjati tri različna besedila, ustvarite tri vrstice.
  • 2.3 V vsako vrstico vnesite obstoječe besede, ki jih boste zamenjali z novo Najdi in nato vnesite nove besede v Zamenjaj stolpec.
  • 2.4 Navedite Vrsta iskanja za vsako vrstico.
  • 2.5 V Poišči v stolpec izberite, kje uporabiti najdi in zamenjaj. Vključuje Glavni dokument, Glava in Noga v tem oddelku. Izberete lahko enega od njih, dva ali vse glede na vaše potrebe.
  • 2.6. Kliknite Zamenjaj za zagon operacije. Oglejte si posnetek zaslona:

Nato se v izbranih dokumentih hkrati nadomestijo določene besede.

Nasvet: Rezultat lahko označite z barvo ozadja, tako da v polju določite določeno barvo Označite stolpec za vrstico.

  Če želite imeti brezplačno (60-dnevno) preskusno različico tega pripomočka, kliknite, če ga želite prenestiin nato nadaljujte z uporabo postopka v skladu z zgornjimi koraki.

Najboljša pisarniška orodja za produktivnost

Kutools za Word - Izboljšajte svojo besedno izkušnjo z Over 100 Izjemne lastnosti!

🤖 Kutools AI pomočnik: Preoblikujte svoje pisanje z AI - Ustvarite vsebino  /  Prepiši besedilo  /  Povzemite dokumente  /  Povprašajte za informacije na podlagi dokumenta, vse v Wordu

📘 Obvladovanje dokumentov: Razdeljene strani  /  Spoji dokumente  /  Izvozi izbor v različnih formatih (PDF/TXT/DOC/HTML ...)  /  Paketna pretvorba v PDF  /  Izvozi strani kot slike  /  Natisnite več datotek hkrati...

Urejanje vsebine: Serijsko iskanje in zamenjava čez več datotek  /  Spremeni velikost vseh slik  /  Prenos vrstic in stolpcev tabele  /  Pretvori tabelo v besedilo...

🧹 Čiščenje brez napora: Pometite stran Dodatni prostori  /  Prelomi oddelkov  /  Vse glave  /  Besedilna polja  /  Hiperpovezave  / Za več orodij za odstranjevanje pojdite na naš Odstrani skupino...

Ustvarjalni vložki: Vstavi Tisoč ločila  /  Potrditvena polja  /  Radijske tipke  /  QR koda  /  Črtna koda  /  Tabela z diagonalno črto  /  Naslov enačbe  /  Opis slike  /  Naslov tabele  /  Več slik  / Odkrijte več v Vstavi skupino...

???? Natančne izbire: Natančna točka določene strani  /  mize  /  Oblike  /  odstavki naslova  / Izboljšajte navigacijo z več Izberite funkcije...

Izboljšave zvezdic: Hitra navigacija do katere koli lokacije  /  samodejno vstavljanje ponavljajočega se besedila  /  brez težav preklapljate med okni dokumentov  /  11 Orodja za pretvorbo...

???? Želite preizkusiti te funkcije? Kutools for Word ponuja a 60-dan brezplačni preskus, brez omejitev! 🚀
 
Comments (23)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
The VBA script you provide here seems to work only for Latin characters; is there some workaround to get special characters to work.
I work with Sanskrit, which used the Devanagari script, similar to Hindi. (1) The VBA does not accept the Devanagai font nor does it find the Latin characters with diacriticals. For example: It fails miserably if I search for mūlādhāra (मूलाधार). It doesn't seem to recognize the ū or ā, for example, and the Devanagari is a complete loss.

Moreover, does the script recognize spaces between words? If not, how do I get them in there?

Thank you!
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
I'm have a similar problem with Sanskrit, not only the Devanagari script but also the English/Latin diacriticals on the special characters like ā, ū, ṛ, ṁ, ṃ, etc. Any suggestions for a workable fix?
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.
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