We help IT Professionals succeed at work.
Get Started

Word VBA: Code to search for text like "AB ######-##" and hyperlink them to Custom URL

885 Views
Last Modified: 2013-11-10
So... I have a ton of word documents with a ton of references in formats like
"AB ######-##"
or
"BC ######-##"
or
"LMN ######-##"
or
(etc., without the quotes, where # is always a number)

...and I need to have Word automatically find them all and hyperlink them (we'll pretend that we need to Google or Yahoo search them). However, here are the conditions:
1. The hyperlink URL cannot include the -. A Replace function to remove these (but leave them in the word document text and leave the link as it originally appeared as text) should be sufficient.
2. Only the code numbers actually get searched. The hyperlink URL prefix and suffix need to be selected (Some sort of select...case) depending on the (two, three, or four)-letter "AB", "BC", "LMN" in front of the number.
3. If the number is not of length 10, add zeros on the left to make it of length 10.

I'm found this code to start things rolling, but I've got no clue what's going on with the findText...
http://www.eggheadcafe.com/software/aspnet/29982909/finding-and-converting-te.aspx
Comment
Watch Question
Social distance; Wear a mask; Don't touch your face; Wash your hands for 20 seconds
CERTIFIED EXPERT
Top Expert 2014
Commented:
This problem has been solved!
Unlock 4 Answers and 15 Comments.
See Answers
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