Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-24-2015, 12:57 AM
gmayor's Avatar
gmayor gmayor is offline VBA Search Table for Text/Select Text/Insert Hyperlink Windows 7 64bit VBA Search Table for Text/Select Text/Insert Hyperlink Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
and call that sub from the original code e.g.

Code:
AddHyperlink ActiveDocument, "Test A", "http:\\www.gmayor.com\WordPages.htm"
You can add any of the other parameters that you require.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
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
VBA Search Table for Text/Select Text/Insert Hyperlink VBA code for Microsoft Word macro — select text and insert footnote ndnd Word VBA 10 01-06-2015 01:47 PM
VBA Search Table for Text/Select Text/Insert Hyperlink Macro to search warning text style and replace the text color rohanrohith Word VBA 3 11-27-2014 01:08 PM
VBA Search Table for Text/Select Text/Insert Hyperlink Select section of text and change text newbieX Word VBA 3 03-28-2014 04:21 PM
VBA Search Table for Text/Select Text/Insert Hyperlink Select Text in Table but Table Gets Selected Too RBusiness Word 1 06-07-2011 04:26 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:42 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft