I have been trying to write a VBA macro (described below) myself for nearly a week and simply do not understand enough about programming to do so. I am hoping someone here will be willing to help me, either privately or here on the forum.
Here is what I am trying to accomplish:
1. When I come to a word or phrase in a document that I want to mark with highlight, I want to select the word and then run the macro.
2. The macro should bring up a message box asking whether I want to highlight the term, Yes, Cancel.
3. If I choose yes, the selected term is highlighted, the term is deselected by moving the cursor to the position immediately following the term, and the macro then (a) inserts a bookmark called markreturn and then ( searches the document forward only for the next instance of that exact term, including case match and any punctuation (the term could be a single word or a phrase, i.e., its character length and content can vary with each running of the macro).
4. If it finds another instance of the term, a message box appears asking if I want to highlight the term, Yes, No, Cancel. Yes highlights the term and then causes the macro to search forward only for the next instance of the exact term; no bookmark is inserted. No skips this instance of the term and searches for the next instance, and if it finds the term, this step is repeated.
5. This process continues until the end of the document is reached or no additional instance of the term is found or Cancel is chosen. In each of these instances, the macro returns to the markreturn bookmark and quits.
6. When the macro quits, the Find term has to be cleared out so that the next time the macro runs (or the next time I do a search with another macro) there is no accumulation of terms.
With some struggle, I was able to write a portion of the macro so that it highlights the selected term in the first instance, but I was unable to figure out how to get it to search again. However, that coding has morphed into something else that doesn’t really work and I (stupidly, I admit) didn’t save iterations of what I was doing. (Can you tell that I’m not much of a programmer?)
Any help will be appreciated. Thank you for your time.
Rich