Function search/replace multiple choice
Hello everyone,
I ask for your help with a problem that I can't solve despite my research.
May be this problem has already been solved but I cannot find the thread.
I want to make a macro that allows the user to search/replace several words in a Word document with a choice in a proposal list (from an Excel table).
The words that need to be replaced in the Word document are coded as following: ZZZ1, ZZZ2, ZZZ3.
Proposals to replace these codes are in an excel table (preview in attached document).
I created a Userform in my Word document (see capture). This one presents a TextBox1 that displays one by one the words to replace (ZZZ1,ZZZ2,ZZZ3) in the Word document.
For each of these codes, there are several alternative options that I would like to see in the ListBox1. All the possibilities associated with each code are listed in an Excel table whose you have the preview below.
The user can then choose which words he wants to replace for example ZZZ1, he selects the remplacement word in the ListBox 1 and then if he presses OK and next, all the occurrences of the word ZZZ1 are replaced by his choice. Then the TextBox 1 presents the following word (example: ZZZ2 if it appears in the Word document otherwise it switches to ZZZ3 etc...) and so forth.
If the user clicks on one of the option button about the customer, I would like the ListBox 1 to pre-select the corresponding replacement word in advance. In this way, the user could click 'Ok at all' to replace all coded words (ZZZ1,ZZZ2,ZZZ3 ....).
Some paragraphs of the Word document may be intended for different customers, hence the possibility for the user to choose the replacement word himself and therefore not to click the 'Ok at all' button but the 'Ok and Next' button. In some cases, there will be only one customer so using the 'Ok at all' button might be interesting...
Hope I managed to be understandable. If you need any further information, please let me know.
I thank in advance all people who can help me.
Many thanks to you and have a nice evening.
|