Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Macro for Word or Excel that changes hyperlink display text to address

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
susan.fineman@verizon.net - 01 Apr 2006 16:14 GMT
I have over 1000 citations for which the article titles are the display
text for the hyperlinks.  For each article I want to change the display
text to the hyperlink address.  I tried recording a new macro, but it
wouldn't record the right-mouse "edit hyperlink" selection.  I couldn't
find a keystroke alternative for selecting edit hyperlink.  I am new to
writing macros in VBA but different postings imply that this is the way
to automate my task.  Can someone please tell me how to write a macro
to accomplish this task?
Helmut Weber - 01 Apr 2006 23:00 GMT
Hi Susan,

maybe the limitations of this aren't relevant for your:

Dim oHpl As Hyperlink
For Each oHpl In ActiveDocument.Hyperlinks
  oHpl.TextToDisplay = oHpl.Address
Next

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

StephanieH - 26 May 2006 20:36 GMT
This is one that I use a lot.  You can alter it for your needs.

Sub HyperChangePlot()

Dim oldtext As String
  Dim newtext As String
  Dim h As Hyperlink
 

      oldtext = "Gross Plotting by Product"
      newtext = "Gross Placement Plotting"
     

For Each h In ActiveSheet.Hyperlinks
      x = InStr(1, h.Address, oldtext)
      If x > 0 Then
          If h.TextToDisplay = h.Address Then
               h.TextToDisplay = newtext
          End If
          h.Address = Application.WorksheetFunction. _
          Substitute(h.Address, oldtext, newtext)
      End If
      Next
End Sub

> Hi Susan,
>
[quoted text clipped - 4 lines]
>    oHpl.TextToDisplay = oHpl.Address
> Next
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.