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?
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?
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
Using keys would be useful if working with multiple word documents.![]()
Please Login or Register to view this content.
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.
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![]()
Please Login or Register to view this content.
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?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks