+ Reply to Thread
Results 1 to 2 of 2

Search keywords in Word 2007 from an Excel table

  1. #1
    Registered User
    Join Date
    03-08-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    2

    Search keywords in Word 2007 from an Excel table

    Basically i have a table in excel full of keywords. I want to create some type of macro in ms word 2007 that would search the word document and highlight any words that appeared in my Excel 2007 table. Any idea's on how this can be achieved?

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Search keywords in Word 2007 from an Excel table

    Without a sample workbook and document it is a little hard to give you an exact answer however I can point you in the right direction.
    First read the document into an array (you could use the filename of the document as a key) - this is using Scripting dictionary object
    Please Login or Register  to view this content.
    Using keys would be useful if working with multiple word documents.
    This will create a string variable called files that is the filename concatenated with "%%%" concatenated with the document text.
    e.g. "word_documentname.docx%%%testdocumentabcWord1word2"
    Then place all the words you want to look for in an excel worksheet and use the Filter function to look for the word e.g.
    Please Login or Register  to view this content.
    You will need to use error handling in case the word is not found. If there is a match you can then highlight the word in the excel document
    This is written as a concept - without a dummy workbook/word document it is hard to give an exact answer. The main point is you can read in a word document into a string and then search the string (either filter function or Instr function to find the word. You would most likely be placing the words you are looking for into an array and search the string with each value in the array.
    As I say this is a general outline and it is written from Excel reading a word document (rather than a word macro doing the work) - it is only a skeleton outline of how to do this but with sample workbook/word document you will have a better chance of getting an answer. Be very specific giving examples of how your workbook is set out with a sample word document and how the workbook should appear after the search. Your request is doable but requires some sample documents - make sure there is no sensitive data in the sample workbook/word document.
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

+ 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