Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2021, 02:08 PM
Thorin23 Thorin23 is offline Function search/replace multiple choice Windows 10 Function search/replace multiple choice Office 2016
Novice
Function search/replace multiple choice
 
Join Date: Apr 2021
Posts: 4
Thorin23 is on a distinguished road
Default 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.
Attached Images
File Type: jpg Reference Table with duplicate .JPG (39.4 KB, 28 views)
File Type: png USERform Word.png (14.8 KB, 28 views)
Attached Files
File Type: xlsx references binder.xlsx (9.0 KB, 8 views)
File Type: docm Example of text.docm (22.0 KB, 9 views)
Reply With Quote
  #2  
Old 05-20-2021, 04:51 PM
LQuinn LQuinn is offline Function search/replace multiple choice Windows 10 Function search/replace multiple choice Office 2019
Novice
 
Join Date: Jan 2021
Location: Western Australia
Posts: 20
LQuinn is on a distinguished road
Default

maybe have a look here and see how you go?
Reply With Quote
  #3  
Old 05-20-2021, 08:08 PM
Guessed's Avatar
Guessed Guessed is online now Function search/replace multiple choice Windows 10 Function search/replace multiple choice Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,989
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #4  
Old 05-22-2021, 03:28 PM
Thorin23 Thorin23 is offline Function search/replace multiple choice Windows 10 Function search/replace multiple choice Office 2016
Novice
Function search/replace multiple choice
 
Join Date: Apr 2021
Posts: 4
Thorin23 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
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?
First of all, thank you to both of you for your interest to my problem and sorry for the delay of my answer.

I recognise this problem requires a lot of work. That's why I manage the word document to another way. I previously said
Quote:
Some paragraphs of the Word document may be intended for different customers
I modified that in order to have one word document for each customer. So the problem is now completely different from the previous one. Indeed, the userform with the textbox and listbox isn't necessary because all could be replaced automatically. The first word of the Word document concerns the customer (Customer 1, Customer 2 etc...).

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.
Attached Files
File Type: docm Example of text.docm (19.4 KB, 6 views)
File Type: xlsx references binder.xlsx (9.5 KB, 6 views)
Reply With Quote
  #5  
Old 05-23-2021, 12:32 AM
macropod's Avatar
macropod macropod is offline Function search/replace multiple choice Windows 10 Function search/replace multiple choice Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Survey with multiple Choice Philipp Lobo Word 1 04-27-2015 05:25 PM
Function search/replace multiple choice Multiple Choice Drop Down List teza2k06 Word 1 04-29-2014 04:54 PM
Function search/replace multiple choice multiple choice question ENEMALI Word VBA 1 09-29-2013 09:05 PM
Function search/replace multiple choice How to make a multiple-choice test? micahfaulkner75 Mail Merge 1 09-12-2012 06:08 PM
Function search/replace multiple choice Multiple choice option boxes burnsie Word 3 07-08-2011 05:10 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft