![]() |
#1
|
|||
|
|||
![]()
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. |
#3
|
||||
|
||||
![]()
In my opinion, the reference that LQuinn posted is interesting but not directly relevant to the question asked.
There is a lot of work to make this happen and to me the requested useability doesn't match the amount of effort to realise this workflow. My questions are: Is this a real task or a vba learning exercise? Is there only ever 4 customers? Is there only ever 3 replaceable items? After an item has been replaced, will you want to find that same location again (linked to the same row) to do another pass?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#4
|
|||
|
|||
![]() Quote:
I recognise this problem requires a lot of work. That's why I manage the word document to another way. I previously said Quote:
So , I think the macro could be (but I don't know how to translate in VBA): -Open the Excel binder - Look at the first column 'code' and "memorize" all the codes - Go to the word document - If the first word of the word document is 'Customer 1' , search all the codes memorized in the document and replace them (and all their occurrences) by the corresponding cells of the excel table (I mean here cells of the column customer 1). - If the first word is 'Customer 2' , search all the codes memorized in the document and replace all the codes (and all their occurrences) by the corresponding cells of the excel table (I mean here cells of the column customer 2) etc ... I attached the new Word Document. I'm really sorry for this changement of problem but you made me realize that this poser requires a lot of work and isn't really pertinent for what I have to do here. To answer your questions: - Yes it's a real task I had to do here. - There is several customers (approximately 10) - So now, for one coded word, there will be just one possible word remplacement . - After an item has been replaced, I don't want to do another pass. Thank you again for your involvement and your help. |
#5
|
||||
|
||||
![]()
I'd suggest you transpose your data and use mailmerge instead of a complex VBA coding exercise to manage the variations.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating a Survey with multiple Choice | Philipp Lobo | Word | 1 | 04-27-2015 05:25 PM |
![]() |
teza2k06 | Word | 1 | 04-29-2014 04:54 PM |
![]() |
ENEMALI | Word VBA | 1 | 09-29-2013 09:05 PM |
![]() |
micahfaulkner75 | Mail Merge | 1 | 09-12-2012 06:08 PM |
![]() |
burnsie | Word | 3 | 07-08-2011 05:10 PM |