Passer au contenu principal

Comment rechercher et remplacer plusieurs mots en même temps dans un document Word?

Word fournit une fonction Rechercher et remplacer pour rechercher toutes les instances d'un mot ou d'une expression et les remplacer par un nouveau mot en même temps. Mais si vous souhaitez rechercher et remplacer différents mots en même temps, cette fonction intégrée ne peut pas vous aider. Dans cet article, nous parlons d'une méthode VBA pour rechercher et remplacer plusieurs mots différents en même temps dans un document Word.

Rechercher et remplacer plusieurs mots en même temps dans Word avec du code VBA
Trouvez et remplacez facilement plusieurs mots en même temps dans Word avec une fonctionnalité incroyable


Rechercher et remplacer plusieurs mots en même temps dans Word avec du code VBA

Veuillez procéder comme suit pour rechercher et remplacer plusieurs mots en même temps dans un document Word.

1. Ouvrez le document Word que vous souhaitez rechercher et remplacer plusieurs mots en même temps, puis appuyez sur le bouton autre + F11 clés pour ouvrir le Microsoft Visual Basic pour applications fenêtre.

2. dans le Microsoft Visual Basic pour applications fenêtre, cliquez sur insérer > Module. Copiez ensuite le code VBA ci-dessous dans la fenêtre Module.

Code VBA: recherchez et remplacez plusieurs mots en même temps dans 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. appuie sur le F5 clé pour exécuter le code.

4. Dans le premier Kutools for Word boîte de dialogue, entrez les mots que vous trouverez et remplacez dans la zone de texte, séparez-les par une virgule, puis cliquez sur le bouton OK bouton. Voir la capture d'écran:

5. Dans le second Kutools for Word boîte de dialogue, entrez les nouveaux mots que vous allez remplacer (ces mots doivent également être séparés par des virgules), puis cliquez sur le bouton OK .

Remarque: Dans ce cas, tous «KTE» dans ce document sera remplacé par "Nouveau", et «KTO» et «KTW» sera remplacé par "Tester" et "Terminer". Veuillez les modifier selon vos besoins.


Trouvez et remplacez facilement plusieurs mots en même temps dans Word avec une fonctionnalité incroyable

La Rechercher et remplacer par lots caractéristique de Kutools for Word peut aider à trouver et remplacer facilement différents textes dans un document ou sur plusieurs documents en même temps.

Avant d'appliquer cette fonctionnalité, veuillez prendre quelques minutes pour téléchargez et installez-le d'abord.

1. Lancez l'application Microsoft Word, cliquez sur Kutools Plus > Rechercher et remplacer par lots.

2. dans le Rechercher et remplacer par lots fenêtre, veuillez configurer comme suit.

  • 2.1 cliquez sur le bouton> Ajouter un fichier or ajouter un dossier pour ajouter un ou plusieurs documents dans lesquels vous trouverez et remplacez plusieurs mots.
  • 2.2 Cliquez sur le Ajouter une rangée pour insérer les champs de recherche et de remplacement. Si vous souhaitez rechercher et remplacer trois textes différents en même temps, veuillez créer trois lignes.
  • 2.3 Dans chaque ligne, entrez les mots existants que vous allez remplacer par un nouveau dans le Trouvez colonne, puis entrez les nouveaux mots dans la remplacer colonne.
  • 2.4 Spécifiez le Type de recherche pour chaque ligne.
  • 2.5 Dans le Retrouver dans colonne, choisissez où appliquer la recherche et le remplacement. Il comprend Document principal, En-tête et Pied de page dans cette section. Vous pouvez en choisir un, deux ou tous en fonction de vos besoins.
  • 2.6. Cliquez sur l' remplacer bouton pour démarrer l'opération. Voir la capture d'écran:

Ensuite, les mots spécifiques sont remplacés dans les documents sélectionnés en même temps.

Conseil: Vous pouvez mettre en évidence le résultat avec une couleur d'arrière-plan en spécifiant une certaine couleur dans le Souligner colonne pour une ligne.

  Si vous souhaitez bénéficier d'un essai gratuit (60 jours) de cet utilitaire, veuillez cliquer pour le télécharger, puis passez à appliquer l'opération selon les étapes ci-dessus.

Meilleurs outils de productivité bureautique

Kutools for Word - Élevez votre expérience Word avec Over 100 Caractéristiques remarquables !

🤖 Assistant IA Kutools: Transformez votre écriture avec l'IA - Générer du contenu  /  Réécrire le texte  /  Résumer des documents  /  Demander des informations basé sur le document, le tout dans Word

(I.e. Maîtrise des documents: Pages divisées  /  Fusionner des documents  /  Exporter la sélection dans différents formats (PDF/TXT/DOC/HTML...)  /  Conversion par lots en PDF  /  Exporter des pages sous forme d'images  /  Imprimer plusieurs fichiers à la fois

Édition du contenu: Rechercher et remplacer par lots sur plusieurs fichiers  /  Redimensionner toutes les images  /  Transposer les lignes et les colonnes du tableau  /  Convertir le tableau en texte

🧹 Nettoyage sans effort : balayer Espaces supplémentaires  /  Sauts de section  /  Tous les en-têtes  /  Boîtes de texte  /  Liens hypertextes  / Pour plus d'outils de suppression, rendez-vous sur notre Supprimer le groupe

Insertions créatives: Insérer Mille séparateurs  /  Cases à cocher  /  Boutons radio  /  code QR  /  Code barres  /  Tableau des lignes diagonales  /  Légende de l'équation  /  Légende  /  Légende de la table  /  Plusieurs images  / Découvrez-en davantage dans le Insérer un groupe

🔍 Sélections de précision: Localiser pages spécifiques  /  les tables  /  formes  /  paragraphes de titre  / Améliorez la navigation avec PLUS Sélectionnez les fonctionnalités

Améliorations des étoiles: Naviguez rapidement vers n’importe quel endroit  /  insertion automatique de texte répétitif  /  basculer de manière transparente entre les fenêtres de document  /  11 outils de conversion

👉 Vous voulez essayer ces fonctionnalités ? Kutools for Word propose un Essai gratuit 60-day, sans aucune limite ! 🚀
 
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