Vai al contenuto principale

Come trovare e sostituire più parole contemporaneamente in un documento di Word?

Word fornisce una funzione Trova e sostituisci per trovare tutte le istanze di una parola o frase e sostituirle contemporaneamente con una nuova parola. Ma se vuoi trovare e sostituire contemporaneamente parole diverse, questa funzione integrata non può aiutarti. In questo articolo, stiamo parlando di un metodo VBA per trovare e sostituire più parole diverse contemporaneamente nel documento di Word.

Trova e sostituisci più parole contemporaneamente in Word con codice VBA
Trova e sostituisci facilmente più parole contemporaneamente in Word con una funzionalità straordinaria


Trova e sostituisci più parole contemporaneamente in Word con codice VBA

Si prega di fare quanto segue per trovare e sostituire più parole contemporaneamente in un documento di Word.

1. Aprire il documento di Word che si desidera trovare e sostituire più parole contemporaneamente, quindi premere il tasto altro + F11 chiavi per aprire il Microsoft Visual Basic, Applications Edition finestra.

2. Nel Microsoft Visual Basic, Applications Edition finestra, fare clic inserire > Modulo. Quindi copia sotto il codice VBA nella finestra del modulo.

Codice VBA: trova e sostituisci più parole contemporaneamente in 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. premi il F5 chiave per eseguire il codice.

4. Nella prima Kutools for Word finestra di dialogo, inserisci le parole multiple che troverai e sostituirai nella casella di testo e separale con una virgola, quindi fai clic su OK pulsante. Vedi screenshot:

5. Nella seconda Kutools for Word finestra di dialogo, immettere le nuove parole con cui sostituire (anche queste parole devono essere separate da virgole), quindi fare clic sul pulsante OK pulsante.

Nota: In questo caso, tutto "KTE" in questo documento verrà sostituito con "Nuovo", ed "KTO" ed "KTW" sarà sostituito con "Test" ed "Finire". Si prega di modificarli in base alle proprie esigenze.


Trova e sostituisci facilmente più parole contemporaneamente in Word con una funzionalità straordinaria

Le Trova e sostituisci in batch caratteristica di Kutools for Word può aiutare a trovare e sostituire facilmente testi diversi in un documento o in più documenti contemporaneamente.

Prima di applicare questa funzione, dedica qualche minuto a scaricalo e installalo prima.

1. Avviare l'applicazione Microsoft Word, fare clic su Kutools Plus > Trova e sostituisci in batch.

2. Nel Trova e sostituisci in batch finestra, configurare come segue.

  • 2.1 fare clic su pulsante> Aggiungi File or aggiungi cartella per aggiungere uno o più documenti in cui troverai e sostituirai più parole.
  • 2.2 Fare clic su Aggiungi riga pulsante per inserire i campi di ricerca e sostituzione. Se desideri trovare e sostituire tre testi diversi contemporaneamente, crea tre righe.
  • 2.3 In ogni riga, inserisci le parole esistenti che sostituirai con una nuova nel file Trovare colonna, quindi inserisci le nuove parole nel file sostituire colonna.
  • 2.4 Specificare il file Tipo di ricerca per ogni riga.
  • 2.5 Nel Trovare in colonna, scegli dove applicare la ricerca e sostituzione. Include Documento principale, testata ed footer in questa sezione. Puoi sceglierne uno, due o tutti in base alle tue esigenze.
  • 2.6. Fare clic sul sostituire pulsante per avviare l'operazione. Vedi screenshot:

Quindi le parole specifiche vengono sostituite contemporaneamente nei documenti selezionati.

Mancia: È possibile evidenziare il risultato con il colore di sfondo specificando un determinato colore nel file Highlight colonna per una riga.

  Se desideri avere una prova gratuita (60 giorni) di questa utility, fare clic per scaricarlo, quindi andare ad applicare l'operazione secondo i passaggi precedenti.

I migliori strumenti per la produttività in ufficio

Kutools for Word - Migliora la tua esperienza con le parole con Over 100 Caratteristiche notevoli!

🤖 Assistente AI di Kutools: Trasforma la tua scrittura con l'intelligenza artificiale - Genera contenuto  /  Riscrivere il testo  /  Riepilogare i documenti  /  Richiedi informazioni sulla base del documento, tutto all'interno di Word

📘 Padronanza dei documenti: Pagine divise  /  Unisci documenti  /  Esporta la selezione in vari formati (PDF/TXT/DOC/HTML...)  /  Converti in batch in PDF  /  Esporta pagine come immagini  /  Stampa più file contemporaneamente...

Modifica dei contenuti: Trova e sostituisci in batch su più file  /  Ridimensiona tutte le immagini  /  Trasporre righe e colonne della tabella  /  Converti tabella in testo...

🧹 Pulito senza sforzo: Spazza via Spazi extra  /  Interruzioni di sezione  /  Tutte le intestazioni  /  Caselle di testo  /  Collegamenti ipertestuali  / Per ulteriori strumenti di rimozione, vai al nostro Rimuovi gruppo...

Inserti creativi: Inserisci Mille separatori  /  Caselle di controllo  /  Pulsanti di scelta  /  QR Code  /  Codice a barre  /  Tabella della linea diagonale  /  Didascalia dell'equazione  /  Didascalia immagine  /  Didascalia  /  Immagini multiple  / Scopri di più nella Inserisci gruppo...

???? Selezioni di precisione: Individuare pagine specifiche  /  con tabelle  /  forme  /  paragrafi di intestazione  / Migliora la navigazione con Scopri di più Seleziona funzionalità...

Miglioramenti delle stelle: Naviga rapidamente verso qualsiasi luogo  /  inserire automaticamente testo ripetitivo  /  passare senza problemi da una finestra all'altra del documento  /  11 strumenti di conversione...

👉 Vuoi provare queste funzionalità? Kutools per Word offre a Prova gratuita 60-day, senza limitazioni! 🚀
 
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