View Single Post
 
Old 10-28-2020, 02:52 PM
rekent rekent is offline Windows 7 64bit Office 2010
Novice
 
Join Date: May 2014
Posts: 22
rekent is on a distinguished road
Default Insert Comments from List for Whole Document and for Only Selected Portion of Document

I am trying to write a macro that enables me to do the following things:

1. Open an UI element and select an option.
2. Search an open document for keywords based on the selected option, where the keywords (or phrases) are located in a separate file with a carriage return between each and the keywords are highlighted in the open document.
3. Add comments from a different user name to some of the located keywords, where the comments are unique to each keyword and are located in a separate file in the format "[keyword] Statement related to keyword."
4. Identify and select a portion of the open document that includes numbers in the format "X."
5. Repeat 2 and 3 above for only the selected portion of the document identified in 4.
6. Find a single specific word in the open document, only in all upper case, and add a comment to that word (word and comment hardcoded, not found in external file).

I have steps 1 and 2 complete and functioning. I know how to change the username for step 3 and how to add comments generally through VBA, but I do not know how to add them unique to the particular keyword that was found (e.g., keyword1:comment1; keyword2:comment2; keyword3:no comment; keyword4:comment4; etc.) based on a listing in an external file.

I also am not certain about how to do steps 4 and 5. I can do step 6 in all regards other than limiting the search to only finding instances of the specific word that are in all capital letters, but I suspect that is likely something trivial to add as a style modifier to the search.

I'm not looking for someone to just write the code for me (though I also wouldn't object since I learn well from examples and working backwards). I've learned a lot already in the parts of the code that I have working and would like to try to figure this out at least semi on my own, but I realize that I am at the outer limits of my ability and am hoping for some input and direction to help me with the above points that have me stumped, especially with respect to step 4. That step has me all-around stumped, including how to set up my external file of keywords and external file of comments so that the keywords and comments for steps 2 and 3 are not used in step 4 and vice versa. I don't know if the code that I have for part 2 would be helpful, but I can post it if needed.
Reply With Quote