Question

  • Creator
    Topic
  • #4217978

    Macro for selecting multiple words simultaneously in Word

    by dpennisi ·

    Hello all,

    Complete newbie here… very little coding/creating macro experience.

    I’ve spent hours looking for a way to simultaneously find multiple words in a single Word document and have them converted to bold text, but am having no luck.

    The Word document in question has a bibliography with hundreds of references with authors listed. I have a separate file with a list of ~300 authors’ names I would like to highlight in the original document. Should be possible, no?

    Does anyone have any pointers? (I hope this is posted with the right tags)

    Many thanks in advance,
    David

You are posting a reply to: Macro for selecting multiple words simultaneously in Word

The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our Community FAQs for details. All submitted content is subject to our Terms of Use.

All Answers

  • Author
    Replies
    • #4217987
      Avatar photo

      Re: select multiple words simultaneously

      by kees_b ·

      In reply to Macro for selecting multiple words simultaneously in Word

      In fact, there are 2 kinds of simultaneous in your question: (1) all occurrences of 1 name, and (2) all occurrences of all names,

      It seems quite possible to write this as a loop over the 300 names in the list. Then for each name, loop over all occurrences in the text.

      I’m afraid you need to either do it manually, or find someone to code it for you. They might want to be paid, if you don’t have friends of family members to do it.

      • #4218943

        Reply To: Macro for selecting multiple words simultaneously in Word

        by dpennisi ·

        In reply to Re: select multiple words simultaneously

        Hi kees_b and alishaalishakhan340,

        Thanks for the responses. I’ll try the macros suggested, otherwise it may require getting someone to write the code!

        Regards,
        David

    • #4220312

      Hi David

      by hassaansiddiqui200215 ·

      In reply to Macro for selecting multiple words simultaneously in Word

      To simultaneously find and convert multiple words to bold text in a Word document, you can use a simple VBA macro. Here’s a basic solution:

      Open your Word document.
      Press Alt + F11 to open the Visual Basic for Applications (VBA) editor.
      Go to Insert > Module to create a new module.
      Copy and paste the following VBA code into the module:

      Sub HighlightWords()
      Dim word As Range
      Dim wordList As Variant
      Dim i As Long

      ‘ List of words to be highlighted
      wordList = Array(“word1”, “word2”, “word3”) ‘ Add your list of authors’ names here

      For i = LBound(wordList) To UBound(wordList)
      With ActiveDocument.Content.Find
      .Text = wordList(i)
      .Forward = True
      .Format = False
      .MatchCase = False
      .MatchWholeWord = True
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False

      Do While .Execute
      If .Found Then
      Set word = Selection.Range
      word.Font.Bold = True
      End If
      Loop
      End With
      Next i
      End Sub

      Customize the wordList array with the list of authors’ names you want to highlight.
      Close the VBA editor and return to your Word document.
      Press Alt + F8, select the “HighlightWords” macro, and click “Run” to execute the macro.
      This macro will search for each word in your list and convert them to bold wherever they are found in the document.

      Hope this helps!

      • #4222961

        Reply To: Macro for selecting multiple words simultaneously in Word

        by dpennisi ·

        In reply to Hi David

        Hi hassaansiddiqui200215,

        Thanks for that – I’ll try this as well as see how it goes.

        Kind regards,
        DP

    • #4230347

      Macro for selecting multiple words simultaneously in Word

      by cassharper030 ·

      In reply to Macro for selecting multiple words simultaneously in Word

      While creating a macro is possible, there’s a simpler way! Here’s how you can find and highlight those authors’ names:

      Open both your document and the list of authors.
      In your document, click the “Find” button (or press Ctrl+H).
      Copy and paste an author’s name from your list into the “Find what” box.
      Click “Format” and choose “Font”. Make sure “Bold” is selected.
      Click “Replace All” (important!). Word will find and bold all instances of that author’s name in your document.
      Repeat steps 3-5 for each author name on your list.

Viewing 2 reply threads