Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-21-2014, 01:00 PM
audioman audioman is offline Find and replace inside strings containing various names Windows 7 64bit Find and replace inside strings containing various names Office 2010 64bit
Novice
Find and replace inside strings containing various names
 
Join Date: Mar 2014
Posts: 7
audioman is on a distinguished road
Default Find and replace inside strings containing various names

I have a Word document which includes many instances of each of the strings shown below. Of course name1, name2 and name3 are actually individual first names.



name1, name2
name1, name2, name3

I'm looking for a macro which with change each of the above strings to
name1 and name2
name1, name2 and name3

Thanks for your help
Reply With Quote
  #2  
Old 03-21-2014, 02:52 PM
macropod's Avatar
macropod macropod is offline Find and replace inside strings containing various names Windows 7 32bit Find and replace inside strings containing various names Office 2010 32bit
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

You can do that with a wildcard Find/Replace, where:
Find = ,([!,^13^l]@[^13^l])
Replace = ^32and\1

No vba required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-24-2014, 05:20 AM
audioman audioman is offline Find and replace inside strings containing various names Windows 7 64bit Find and replace inside strings containing various names Office 2010 64bit
Novice
Find and replace inside strings containing various names
 
Join Date: Mar 2014
Posts: 7
audioman is on a distinguished road
Default Almost worked

Thanks for your answer. However, I didn't provide enough information. The document format is:

First Item: some variable information
Second Item: more variable information
Third Item: still more
Fourth Item: even more
Fifth Item: name1, name2 (or name1, name2, name3)

The above pattern repeats 5 or 10 times in the document. Your code does a great job at inserting the "and" as I requested. However, it also places the "and" in other places in the document, like at the beginning of each new line. I'm going to see if I can work with your suggestion but would appreciate any additional help.
Reply With Quote
  #4  
Old 03-24-2014, 02:31 PM
macropod's Avatar
macropod macropod is offline Find and replace inside strings containing various names Windows 7 32bit Find and replace inside strings containing various names Office 2010 32bit
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

It would probably be impossible for a Find/Replace, and even for a macro, to identify with certainty when you do or don't want a particular comma replaced. The Find/Replace works 100% with the sample data you have posted so far. Obviously, though, if you have a sentence like:
First Item: some variable information, but not all
there's no way to know the comma's not one you want to replace.

I don't see how the F/R could possibly insert 'and' at the beginning of a line, unless that line begins with a comma (which would be quite unusual).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 03-25-2014, 11:19 AM
audioman audioman is offline Find and replace inside strings containing various names Windows 7 64bit Find and replace inside strings containing various names Office 2010 64bit
Novice
Find and replace inside strings containing various names
 
Join Date: Mar 2014
Posts: 7
audioman is on a distinguished road
Default It works!!

Thanks for the code. I made a typo when transferring the code you provided. When I corrected my error, it worked beautifully.
Thanks again, I really appreciate your expert help and knowledge.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and replace inside strings containing various names How To Find Bookmarks and/or custom fields Inside Building Blocks, Office 2010 thpanos Word 3 02-17-2013 08:49 AM
Find and replace inside strings containing various names Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
Where we can find a Word document (docx file) that contains professional work inside? Jamal NUMAN Word 0 06-26-2011 09:57 AM
Find and replace inside strings containing various names update style of all strings available between two specific strings vikrantkale Word 1 03-28-2011 06:13 PM
find author names in text anil3b2 Word 0 08-02-2010 04:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:55 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