![]() |
|
#4
|
||||
|
||||
|
If you want to use the original string as the display text then modify the original macro as follows:
Code:
Sub AddHLink()
Dim oRng As Range
Dim strLink As String
Set oRng = ActiveDocument.Range
With oRng.Find
Do While .Execute(FindText:="([A-Z]{2}) ([0-9]{4,}) ([A-Z0-9]{1,2})", MatchWildcards:=True)
strLink = oRng.Text
strLink = Replace(strLink, Chr(32), "")
strLink = "https://www.google.co.in/patents/" & strLink & "?cl=en \t _blank"
ActiveDocument.Hyperlinks.Add Anchor:=oRng, _
Address:=strLink, _
TextToDisplay:=oRng.Text
oRng.End = oRng.Fields(1).Result.End
oRng.Collapse 0
Loop
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
| Tags |
| microsoft word, vba, wildcard |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VBA Search Table for Text/Select Text/Insert Hyperlink | sldrellich | Word VBA | 3 | 03-24-2015 01:09 PM |
| Insert a hyperlink in body of email | ChuckDrago | Outlook | 0 | 06-28-2013 06:51 AM |
Insert the Hyperlink and hide all sheets except clicking Hyperlink
|
PRADEEPB270 | Excel | 1 | 02-22-2013 09:47 AM |
| Hyperlink/Data Insert & replace | jclinton | Word | 1 | 09-19-2012 07:22 PM |
| Insert Hyperlink - Differing Functionality | nell3773 | Word | 0 | 04-30-2010 12:23 PM |