Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-09-2021, 11:42 AM
laith93 laith93 is offline Find and replace words according to excel file Windows 10 Find and replace words according to excel file Office 2019
Competent Performer
Find and replace words according to excel file
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Post Find and replace words according to excel file

Hi,
I have a list of words and abbreviations in an excel file,
I want to use this list to search and replace words in a word document, and if possible to preserve words formating in the excel file during replacing, eg:

Demo:
Urinary tract infection (uti) are considered to be the most common and important bacterial infection, elisa test, E. coli most common infectious agent.

Excel file with desired formatting words:
UTI
ELISA
E. coli



After applying code:
Urinary tract infection (UTI) are considered to be the most common and important bacterial infection, ELISA test, E. coli most common infectious agent.

Please any help?
Thank you
Reply With Quote
  #2  
Old 12-09-2021, 03:20 PM
Guessed's Avatar
Guessed Guessed is offline Find and replace words according to excel file Windows 10 Find and replace words according to excel file Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,980
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

Search and replace from an Excel table is relatively straightforward but if you want to include formatting as well it becomes a whole different ballgame.

I would recommend the source table be in Word format so you have more flexible formatting options which don't require special handling. Are you able to set up a Word source for the replacements or does it HAVE to be in Excel?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 12-09-2021, 08:14 PM
laith93 laith93 is offline Find and replace words according to excel file Windows 10 Find and replace words according to excel file Office 2019
Competent Performer
Find and replace words according to excel file
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post

I would recommend the source table be in Word format so you have more flexible formatting options which don't require special handling.
Thank you for your reply Mr. Andrew
Good idea
Reply With Quote
  #4  
Old 12-09-2021, 08:21 PM
laith93 laith93 is offline Find and replace words according to excel file Windows 10 Find and replace words according to excel file Office 2019
Competent Performer
Find and replace words according to excel file
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
Are you able to set up a Word source for the replacements or does it HAVE to be in Excel?
It doesn't matter, as you like, it's just an idea by me (according to an excel file), but keep in your mind Mr. Adrew
I want to ignore cases during searching, e.g

Search for: fimH and fyuA, FimH, FyuA, FIMH, FYUA (the same abbreviations)
Replace to: fimH and fyuA

See attachment files with my special thanks.
Attached Files
File Type: docx Demo.docx (18.2 KB, 4 views)
File Type: docx WordList.docx (18.5 KB, 4 views)
Reply With Quote
  #5  
Old 12-09-2021, 09:38 PM
gmayor's Avatar
gmayor gmayor is offline Find and replace words according to excel file Windows 10 Find and replace words according to excel file Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

See https://www.gmayor.com/document_batch_processes.htm which will process all the document ranges and will include the formatting in the table.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #6  
Old 12-10-2021, 11:54 AM
laith93 laith93 is offline Find and replace words according to excel file Windows 10 Find and replace words according to excel file Office 2019
Competent Performer
Find and replace words according to excel file
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
See https://www.gmayor.com/document_batch_processes.htm which will process all the document ranges and will include the formatting in the table.
Thank Mr. Ghram for this awesome and great add-in
Excuse me Mr. Ghram, can you clarify these points:

1:
I want to replace fimH, FimH, and FIMH to fimH, so I used different combination by typing (Y,N,N), (N,Y,N), (Y,Y,N), ...etc
but without benefit, so which combination is better for this case?

2:
When I left the columns (WC, WWo, OMIT) blanks, it does affect the results?

3:
When I type (Y) for a certain column, is necessary to type (N) for other columns?

4:
I didn't understand (OMIT) what can do, I want more explanation, please?

5:
I added (Process Documents) to QAT, so I want to hide Batch Process tab.

Thank you again
Reply With Quote
  #7  
Old 12-10-2021, 10:33 PM
gmayor's Avatar
gmayor gmayor is offline Find and replace words according to excel file Windows 10 Find and replace words according to excel file Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

To replace fimH, FimH, and FIMH with fimH you will need three rows in the table with (or nothing) in the WC column.
It is not necessary to enter N. The process looks for Y.
If the OMIT column has Y then that row is not included in the process.
The only way to remove the Batch Process tab would be to use the Office Ribbon X editor to remove the add-in's ribbon. I would caution against doing so as it may render the process unusable.
If you use it only occasionally, you may find Load Word add-ins for the current session only useful.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #8  
Old 12-13-2021, 08:11 PM
laith93 laith93 is offline Find and replace words according to excel file Windows 10 Find and replace words according to excel file Office 2019
Competent Performer
Find and replace words according to excel file
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
To replace [FONT=&quot]fimH, FimH, and FIMH with fimH you will need three rows in the table with (or nothing) in the WC column.
Thank you, I have got the idea.

Quote:
Originally Posted by gmayor View Post
[FONT=&quot]The only way to remove the Batch Process tab would be to use the Office Ribbon X editor to remove the add-in's ribbon. I would caution against doing so as it may render the process unusable.
Ok, Mr. Graham
My problem with this tab is taking large space and you can't rearrange it or add custom commands to this tab, because it hidden by default
04.png

Quote:
Originally Posted by gmayor View Post
[FONT=&quot]It is not necessary to enter N. The process looks for Y.
Lastly, Mr. Graham
I made my table without entering (Y or N) to any column, and it produces my desired results, so I think Y or N is not necessary in my case, is right??? see
12.png

Thank you
Reply With Quote
Reply

Tags
find & replace, vba code, word vba code



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and replace words according to excel file Find & Replace Multiple words Gartholameau Word VBA 2 01-20-2019 04:56 PM
Find and replace words according to excel file multiple find and replace in vba for special words kvnrao Word VBA 7 11-02-2018 06:28 PM
Find and replace words according to excel file Find and replace mutiple spaces between lowercase words only Dave T Word VBA 2 07-16-2015 11:23 PM
Find and replace words according to excel file VBA Batch Find & Replace for all MSOffice extensions, to replace File Name and Content of the File QA_Compliance_Advisor Word VBA 11 09-11-2014 11:51 PM
Find and replace words according to excel file Find & Replace: substitute red-coloured words with underscores tinfanide Word 2 10-06-2012 11:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:29 PM.


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