View Single Post
 
Old 11-05-2022, 10:27 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,138
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

The macro I posted adds the hyperlink to the hyperlink text. If you want it at that new location see below. It is not clear whether you want to move the link or copy it at that location. If you want it copied, remove the line oRng.Text = ""




Code:
Sub Macro1()
Dim oRng As Range
Dim sLink As String
Selection.HomeKey    'start of paragraph
    Set oRng = Selection.Paragraphs(1).Range
    oRng.End = oRng.End - 1
    sLink = oRng.Text

    'remove the original hyperlink
    oRng.Text = ""

    'set the range to the new location
    oRng.MoveStartUntil "-", wdBackward
    oRng.Start = oRng.Start - 2
    'collapse the range to its start
    oRng.Collapse 1
    'add the hyperlink
    oRng.Hyperlinks.Add oRng, sLink
    Set oRng = Nothing
End Sub
__________________
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