メインコンテンツへスキップ

Word文書で同時に複数の単語を見つけて置き換える方法は?

Wordには、単語またはフレーズのすべてのインスタンスを検索し、それらを同時に新しい単語に置き換えるための検索と置換機能があります。 ただし、異なる単語を同時に検索して置換したい場合は、この組み込み関数は役に立ちません。 この記事では、Word文書内の複数の異なる単語を同時に検索して置換するVBAメソッドについて説明します。

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 for Word ダイアログボックスで、見つけて置き換える複数の単語をテキストボックスに入力し、カンマで区切ってから、 OK ボタン。 スクリーンショットを参照してください:

5番目に Kutools for Word ダイアログボックスで、置き換える新しい単語を入力し(これらの単語もコンマで区切る必要があります)、[ OK

注: この場合、すべて 「KTE」 このドキュメントでは、 "新着"、 & 「KTO」 & 「KTW」"テスト" & 「終了」。 必要に応じて変更してください。


Wordで同時に複数の単語を簡単に見つけて、すばらしい機能で置き換えることができます

  バッチ検索と置換 の特徴 Kutools for Word ドキュメント内または複数のドキュメント間で同時に異なるテキストを簡単に見つけて置き換えるのに役立ちます。

この機能を適用する前に、数分かかります 最初にダウンロードしてインストールします.

1. Microsoft Wordアプリケーションを起動し、をクリックします クツールズプラス > バッチ検索と置換.

2。 の中に バッチ検索と置換 ウィンドウは、次のように構成してください。

  • 2.1クリック ボタン> ファイルを追加 or フォルダの追加 複数の単語を見つけて置き換えるXNUMXつ以上のドキュメントを追加します。
  • 2.2 行を追加する ボタンをクリックして、検索フィールドと置換フィールドを挿入します。 XNUMXつの異なるテキストを同時に検索して置換する場合は、XNUMXつの行を作成してください。
  • 2.3各行に、新しい単語に置き換える既存の単語を入力します。 もう完成させ、ワークスペースに掲示しましたか? 列をクリックしてから、新しい単語を 交換する コラム。
  • 2.4指定する 検索の種類 各行に対して。
  • 2.5で で見つける 列で、検索と置換を適用する場所を選択します。 含まれています メインドキュメント, ヘッダ & フッター このセクションで。 必要に応じて、XNUMXつ、XNUMXつ、またはすべてを選択できます。
  • 2.6。 クリック 交換する ボタンをクリックして操作を開始します。 スクリーンショットを参照してください:

次に、選択したドキュメント内の特定の単語が同時に置き換えられます。

ヒント: で特定の色を指定することにより、背景色で結果を強調表示できます。 特徴 行の列。

  このユーティリティの無料トライアル(60日)が必要な場合は、 クリックしてダウンロードしてください、次に、上記の手順に従って操作を適用します。

最高のオフィス生産性向上ツール

Kutools for Word - Over で単語体験を向上させましょう 100 注目すべき機能!

🤖 Kutools AI アシスタント: AI であなたの文章を変革します - コンテンツを生成する  /  テキストを書き換える  /  文書を要約する  /  情報のお問い合わせ 文書に基づいて、すべて Word 内で

📘 ドキュメントマスタリー: 分割ページ  /  ドキュメントをマージする  /  選択内容をさまざまな形式でエクスポート (PDF/TXT/DOC/HTML...)  /  PDFへの一括変換  /  ページを画像としてエクスポート  /  複数のファイルを一度に印刷する...

コンテンツ編集: バッチ検索と置換 複数のファイルにわたる  /  すべての画像のサイズを変更する  /  テーブルの行と列を転置する  /  表をテキストに変換...

🧹 楽にお掃除:振り払って 余分なスペース  /  セクションブレーク  /  すべてのヘッダー  /  テキストボックス  /  ハイパーリンク  / その​​他の取り外しツールについては、当社の Web サイトをご覧ください。 グループを削除...

クリエイティブインサート:挿入 千の区切り文字  /  チェックボックス  /  ラジオボタン  /  QRコード  /  バーコード  /  斜線テーブル  /  方程式のキャプション  /  画像キャプション  /  テーブルキャプション  /  複数の写真  / 詳細については、 グループを挿入...

🔍 正確な選択: ピンポイント 特定のページ  /  テーブル  /  シェイプ  /  見出し段落  / ナビゲーションを強化する 他には? 機能の選択...

スターの強化: あらゆる場所に素早く移動  /  繰り返しのテキストを自動挿入  /  ドキュメントウィンドウをシームレスに切り替える  /  11 変換ツール...

👉 これらの機能を試してみませんか? Kutools for Wordは、 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