Avatar of Jeff McClellan
Jeff McClellan
Flag for United States of America asked on

VBA code that loops through a document to find defined text in a text string, go to the end of that text string, and insert a character (~) before/after the next paragraph mark

I want to use VBA / Word macro that will add a "~" character (or some unique symbol) at the end of every line where "http://" occurs and before/after the next line break/paragraph mark.  

1.  Search for an instance of the search text.  In this case "http://"
2. Find the next paragraph mark (line break) immediately after the search text.
3. Insert a "~" character immediately before (or after) the paragraph mark (line break).

Here is an example of the text I want to apply that to:

Ag Analytical Services Lab
• Soil Program 4x Year
Spargo, John T.
University Park, PA, 16802
USA
Tel: 814-863-0841
Fax: 814-863-4540
jts29@psu.edu
http://www.aasl.psu.edu
AGAT Laboratories - Burnaby
• Soil and Plant Program
Pahl, Mackenzie
Burnaby, BC, V5J 0B6
CANADA
Tel: 778-452-4000
Fax: 778-452-4074
pahl@agatlabs.com
http://www.agatlabs.com
AGAT Laboratories - Mississauga
• Soil and Plant Program 2x Year
Boulton, Nick
Mississauga, ON, L4Z 1Y2
CANADA
Tel: 905-712-5075
Fax: 905-501-0589
boulton@agatlabs.com
http://www.agatlabs.com
AgLab Express
• Soil and Plant Program
Barber, Michael
Sioux Falls, SD, 57105-6411
USA
Tel: 605-271-9237
Fax: 605-271-9238
mikebarber@aglabexpress.com
http://aglabexpress.com
Microsoft WordVBA

Avatar of undefined
Last Comment
Jeff McClellan

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Paul Cook-Giles

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jeff McClellan

ASKER
Works like a charm
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck