I need to fix some hyperlinks. The file names are the same; it's just the address in front of the last "\" that needs to change. The code I have is below, but I cannot get it to work. Any suggestions are greatly appreciated.
Code:
Sub FixHyperlinks()
Dim NewPath As String
Dim NewfName As String
Dim GetFilenameFromPath As String
Dim oColumn As Range
Set oColumn = GetColumn(1)
Dim oCell As Range
For Each oCell In oColumn.Cells
If oCell.Hyperlinks.Count > 0 Then
Call GetAddress
Dim oHyperlink As Hyperlink
Set oHyperlink = oCell.Hyperlinks(1) ' I assume only 1 hyperlink per cell
Dim strResult As String
strResult = oCell.Hyperlinks.Address
strPath = strResult
NewPath = "\\marnv006\Bm\Master Scheduling\PC 2.2.11 Work Authorizing Memorandum (WAMs)\WAMS added to WAM Track\"
NewfName = NewPath & GetFilenameFromPath
End If
Next oCell
End Sub
Function GetAddress(HyperlinkCell As Range)
GetAddress = Replace(HyperlinkCell.Hyperlinks(1).Address, "mailto:", "")
End Function
Function FunctionGetFileName(FullPath As String) As String
'Update 20140210
Dim splitList As Variant
splitList = VBA.Split(FullPath, "\")
FunctionGetFileName = splitList(UBound(splitList, 1))
End Function
Private Function GetColumn() As Range
Set GetColumn = ActiveWorkbook.Worksheets(1).Range("A:A")
End Function