Прескочи на основното съдържание

Как да намерите и замените няколко думи едновременно в документ на Word?

Автор: Силувия Последна промяна: 2020-07-22

Word предоставя функция за намиране и замяна, за да намерите всички случаи на дума или фраза и да ги замените с нова дума едновременно. Но ако искате да намерите и замените различни думи едновременно, тази вградена функция не може да помогне. В тази статия говорим за метод на VBA за намиране и заместване на няколко различни думи едновременно в документ на Word.

Намерете и заменете няколко думи едновременно в Word с VBA код
Лесно намирайте и замествайте няколко думи едновременно в Word с невероятна функция


Намерете и заменете няколко думи едновременно в Word с VBA код

Моля, направете следното, за да намерите и замените няколко думи едновременно в документ на Word.

1. Отворете документа на Word, който искате да намерите и замените няколко думи едновременно, след което натиснете Друг + F11 за да отворите Microsoft Visual Basic за приложения прозорец.

2. В Microsoft Visual Basic за приложения прозорец, кликнете Поставете > Модул. След това копирайте по-долу VBA кода в прозореца на модула.

VBA код: Намерете и заменете няколко думи едновременно в 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. Натисни F5 ключ за изпълнение на кода.

4. В първия Kutools за Word диалогов прозорец, въведете няколкото думи, които ще намерите и замените в текстовото поле, и ги разделете със запетая, след което щракнете върху OK бутон. Вижте екранна снимка:

5. Във втория Kutools за Word диалогов прозорец, въведете новите думи, с които ще замените (тези думи също трябва да бъдат разделени със запетаи), след което щракнете върху OK бутон.

Забележка: В този случай всички „KTE“ в този документ ще бъдат заменени с „Ново“, намлява „KTO“ намлява „KTW“ ще бъдат заменени с "Тест" намлява "Завършек". Моля, променете ги според вашите нужди.


Лесно намирайте и замествайте няколко думи едновременно в Word с невероятна функция

- Пакетно намиране и замяна функция на Kutools за Word може да помогне за лесно намиране и замяна на различни текстове в документ или в множество документи едновременно.

Преди да приложите тази функция, моля, отделете минути за първо го изтеглете и инсталирайте.

1. Стартирайте приложението Microsoft Word, щракнете Kutools плюс > Пакетно намиране и замяна.

2. В Пакетно намиране и замяна прозорец, моля, конфигурирайте както следва.

  • 2.1 щракнете върху бутон> Добавяне на файл or Добавяне на папка за да добавите един или повече документи, в които ще намерите и замените няколко думи.
  • 2.2 Кликнете върху Добавяне на ред бутон за вмъкване на полетата за намиране и замяна. Ако искате да намерите и замените три различни текста едновременно, моля, създайте три реда.
  • 2.3 Във всеки ред въведете съществуващите думи, които ще замените с нови в Какво и след това въведете новите думи в Сменете колона.
  • 2.4 Посочете Тип на търсене за всеки ред.
  • 2.5 В Открий в изберете къде да приложите намирането и замяната. Включва Основен документ, Header намлява Footer В тази секция. Можете да изберете един от тях, два от тях или всички въз основа на вашите нужди.
  • 2.6. Щракнете върху Сменете бутон за стартиране на операцията. Вижте екранна снимка:

След това конкретните думи се заменят едновременно в избрани документи.

Съвет: Можете да маркирате резултата с цвят на фона, като посочите определен цвят в Маркирайте колона за ред.

  Ако искате да имате безплатен пробен период (60 дни) на тази помощна програма, моля, щракнете, за да го изтеглитеи след това преминете към прилагане на операцията съгласно горните стъпки.

Най-добрите инструменти за продуктивност в офиса

Kutools за Word - Подобрете своя Word опит с Over 100 Забележителни функции!

🤖 Kutools AI Assistant: Преобразувайте писането си с AI - Генериране на съдържание  /  Пренаписване на текст  /  Обобщаване на документи  /  Запитване за информация въз основа на Документ, всичко това в Word

📘 Владеене на документи: Разделяне на страници  /  Обединяване на документи  /  Експортиране на селекция в различни формати (PDF/TXT/DOC/HTML...)  /  Пакетно конвертиране в PDF  /  Експортиране на страници като изображения  /  Отпечатайте няколко файла наведнъж...

Редактиране на съдържанието: Пакетно намиране и замяна в множество файлове  /  Преоразмеряване на всички снимки  /  Транспониране на редовете и колоните на таблицата  /  Преобразуване на таблица в текст...

🧹 Почистване без усилие: Изметете Допълнителни пространства  /  Прекъсвания на раздели  /  Всички заглавки  /  Текстови полета  /  Хипервръзки  / За повече инструменти за премахване се насочете към нашия Премахване на група...

Творчески вложки: Вмъкване Хилядни разделители  /  Квадратчета  /  Радио бутони  /  QR Code  /  Баркод  /  Таблица с диагонални линии  /  Надпис на уравнение  /  Надпис на изображението  /  Надпис на таблица  /  Множество снимки  / Открийте повече в Вмъкване на група...

🔍 Прецизни селекции: Точна точка конкретни страници  /  таблици  /  форми  /  заглавни параграфи  / Подобрете навигацията с още Изберете функции...

Звездни подобрения: Навигирайте бързо до всяко място  /  автоматично вмъкване на повтарящ се текст  /  безпроблемно превключване между прозорците на документи  /  11 Инструменти за конвертиране...

👉 Искате ли да изпробвате тези функции? Kutools за Word предлага a 60-дневен безплатен пробен период, без ограничения! ????
 
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