Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Change all hyperlink addresses (Network paths) on the active worksheet using VBA

Avatar of Andreas Hermle
Andreas HermleFlag for Germany asked on
Microsoft OfficeMicrosoft ExcelVBA
1 Comment1 Solution162 ViewsLast Modified:
Dear Experts:

below macro adds the substring _bw at the end of every hyperlink address such as ...

C:\test\MyProduct.pdf  (Before)
C:\test\MyProduct_bw.pdf  (After)

Could somebody please rewrite / tweak the code so that the other way round is also possible, i.e. I would like to delete the substring  _bw from the end of every hyperlink address.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

Sub UpdateHyperLink()
    Dim hLink As Hyperlink
    Dim wSheet As Worksheet
    Dim Link, StartNum, EndNum, StrFound
    Set wSheet = ActiveWorkbook.ActiveSheet
    For Each hLink In wSheet.Hyperlinks
         Link = hLink.Address
         Link = Replace(Link, Right(Link, 4), "_bw" & StrFound & Right(Link, 4))
         hLink.Address = Link
    Next hLink
End Sub

Function FindN(sFindWhat As String, sInputString As String, N As Integer) As Integer
    Dim J As Integer
    FindN = 0
    For J = 1 To N
        FindN = InStr(FindN + 1, sInputString, sFindWhat)
        If FindN = 0 Then Exit For
End Function
Avatar of Rey Obrero (Capricorn1)
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answers