![]() |
#2
|
||||
|
||||
![]()
You could use something like
Code:
Sub AddHyperlink(oDoc As Document, _ strText As String, _ strLink As String) Dim oTable As Table Dim oRng As Range Set oTable = oDoc.Tables(1) Set oRng = oTable.Range With oRng.Find Do While .Execute(FindText:=strText) oDoc.Hyperlinks.Add Anchor:=oRng, _ Address:=strLink, _ SubAddress:="", _ ScreenTip:="", _ TextToDisplay:=oRng.Text, _ Target:="" oRng.Collapse 0 Exit Do Loop End With lbl_Exit: Exit Sub End Sub Code:
AddHyperlink ActiveDocument, "Test A", "http:\\www.gmayor.com\WordPages.htm"
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Microsoft Word macro to find text, select all text between brackets, and delete | helal1990 | Word VBA | 4 | 02-05-2015 03:52 PM |
![]() |
ndnd | Word VBA | 10 | 01-06-2015 01:47 PM |
![]() |
rohanrohith | Word VBA | 3 | 11-27-2014 01:08 PM |
![]() |
newbieX | Word VBA | 3 | 03-28-2014 04:21 PM |
![]() |
RBusiness | Word | 1 | 06-07-2011 04:26 PM |