By using t2do.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

T2Do.com

 


VBA Code to ExtractTextFromLink

Function ExtractTextFromLink(sText)
'pass a hyperlink and returns the text
'if no hyperlink then just return entire text

sOrig = sText

ExtractTextFromLink = sText
'sText = Replace(sText, """", """""") replace

lStart = InStr(sOrig, "<a")
If lStart > 0 Then
    'ok
Else
    Exit Function
End If

lEnd = InStr(lStart + 1, sText, ">")
If lEnd = 0 Then
    Exit Function ' not well formed a <link>
End If

sText = RemoveText(sText, lStart, lEnd)

lStart = InStr(sText, "</a>")
If lStart > 0 Then
    sText = RemoveText(sText, lStart, lStart + 3)
End If


ExtractTextFromLink = sText

End Function