Link to home
Create AccountLog in
Avatar of Jeff McClellan
Jeff McClellanFlag 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
ASKER CERTIFIED SOLUTION
Avatar of Paul Cook-Giles
Paul Cook-Giles
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Jeff McClellan

ASKER

Works like a charm