+ Reply to Thread
Results 1 to 6 of 6

Macro that can search a database and highlight multiple words

  1. #1
    Registered User
    Join Date
    04-18-2012
    Location
    Norway, Ålesund
    MS-Off Ver
    Microsoft office 2010/2013
    Posts
    51

    Macro that can search a database and highlight multiple words

    Hello, I need some help making some macros and a database. How can I make a code that will search every word in Word and lookup that word in a database and if it is a match it will highlight all the different words (I know how to use the search code, but not how to make a database and search multiple words and highlight them). The database needs have data entries, a word to look up and word that can be replaced with it (like a table in excel where column A is the word to search for and column B is the word to replace it with). Is there anyone that can help me, or know some parts that will make it easier for me (I do not know if it is possible to make a database (maybe access?), any help would be appreciated!!!)?


    Summary:
    1 Make a database to be used in vba
    2 Make a macro that searches the document for words that matches the in the database and highlights them (different words)
    3 Make a macro that searches the document for words that matches the in the database, and replace it with the another word

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Macro that can search a database and highlight multiple words

    See: http://www.msofficeforums.com/word-v...d-replace.html
    The only difference from a Find/Replace perspective for replacing vs highlighting is whether you're replacing the found string with another one or adding a highlight. In fact, the two can be combined.

    Recording Find/Replace macros with replacement vs highlighting will show you how little difference there is between the two.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    04-18-2012
    Location
    Norway, Ålesund
    MS-Off Ver
    Microsoft office 2010/2013
    Posts
    51

    Re: Macro that can search a database and highlight multiple words

    Thank you! This helped me alot I think I have to do some minor changes, so I will leave the thread unsolved. But I think you solved my problem :D

  4. #4
    Registered User
    Join Date
    04-18-2012
    Location
    Norway, Ålesund
    MS-Off Ver
    Microsoft office 2010/2013
    Posts
    51

    Re: Macro that can search a database and highlight multiple words

    Could you please modify the code so it only works in the document that is activated and not in the folder that is selected, and if I use find, how do I mark multiple words with the yellow highlight marker?

  5. #5
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Macro that can search a database and highlight multiple words

    For code to run against the active document only, see:
    http://www.msofficeforums.com/word-v...html#post31726
    To highlight the replaced text is as simple as adding:
    .Replacement.Highlight = True
    to the Find/Replace portion of the code.

  6. #6
    Registered User
    Join Date
    04-18-2012
    Location
    Norway, Ålesund
    MS-Off Ver
    Microsoft office 2010/2013
    Posts
    51

    Re: Macro that can search a database and highlight multiple words

    Thank you!!!! :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1