Code:
Sub BBCodeTagsURL_() ' https://eileenslounge.com/viewtopic.php?p=315503#p315503 https://www.excelfox.com/forum/showthread.php/2860-Notes-tests-string-manipulation-of-text-files-and-string-manipulations?p=24092&viewfull=1#post24092
Rem 0 The text you selected
Dim SelTxt As String
Let SelTxt = Selection.Text ' A text I highlighted in Word
Rem 1 Some groups of name, URL, pairs
Dim strItAll As String, strEileen As String, strFox As String
Let strEileen = "Eileen's Lounge, https://eileenslounge.com/app.php/portal, eileenslounge, https://eileenslounge.com/app.php/portal, The Windows Clipboard, https://www.eileenslounge.com/viewtopic.php?p=300947#p300947, "
Let strFox = "Excel Fox, https://www.excelfox.com/forum/forum.php, excelfox, https://www.excelfox.com/forum/forum.php, "
Let strItAll = strEileen & strFox
Rem 2 Find the URL if there is one
Dim strURL As String
If InStr(1, strItAll, SelTxt, vbTextCompare) > 0 Then
Let strURL = Mid(strItAll, InStr(InStr(1, strItAll, SelTxt, vbTextCompare), strItAll, "http", vbBinaryCompare), InStr(InStr(InStr(1, strItAll, SelTxt, vbTextCompare), strItAll, "http", vbBinaryCompare), strItAll, ",", vbBinaryCompare) - InStr(InStr(1, strItAll, SelTxt, vbTextCompare), strItAll, "http", vbBinaryCompare))
Else
Let strURL = ""
End If
Rem 3 Make the BB Code Tag URL thing
Call MakeABBCodeTagURL(strURL)
End Sub
Sub MakeABBCodeTagURL(ByVal strURL As String) ' https://www.excelfox.com/forum/showthread.php/2860-Notes-tests-string-manipulation-of-text-files-and-string-manipulations?p=24092&viewfull=1#post24092
With Selection
.Text = "[URL=" & strURL & "] " & .Text & " [/url]"
.Collapse Direction:=wdCollapseEnd
.Font.Color = wdColorAutomatic
End With
End Sub
Bookmarks