We help IT Professionals succeed at work.
Get Started

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

Jeff McClellan
on
230 Views
Last Modified: 2017-03-31
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
Comment
Watch Question
Senior Application Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE