View Single Post
 
Old 03-24-2015, 01:09 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub ForNovive()
  AddHyperlink ActiveDocument, "App A.", "C:\\My Documents\File\Appendix A.docx"
End Sub
Sub AddHyperlink(oDoc As Document, _
                 strText As String, _
                 strLink As String)
Dim oTbl As Table
Dim oHL As Hyperlink
Dim oRng As Range, oHLRange
  For Each oTbl In oDoc.Tables
    Set oRng = oTbl.Range
    With oRng.Find
      .Wrap = wdFindStop
      Do While .Execute(FindText:=strText)
        Set oHL = oDoc.Hyperlinks.Add(Anchor:=oRng.Duplicate, _
                  Address:=strLink, SubAddress:="", _
                  ScreenTip:="", TextToDisplay:=oRng.Duplicate.Text, _
                  Target:="")
        oRng.Start = oHL.Range.End
      Loop
    End With
  Next oTbl
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote