Code: Select all
Sub makeURLs()
Dim oDocument As Object
Dim oSearch As Object, oFound As Object
Dim oFoundCursor As Object
Dim reURL As String
Dim doistring as String
Dim URL as String
reURL = "(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)"
URL = ""
doistring = "dx.doi.org"
oDocument = ThisComponent
oSearch = oDocument.createSearchDescriptor
oSearch.SearchRegularExpression = TRUE
oSearch.SearchString = reURL
oFound = oDocument.findFirst(oSearch)
While NOT IsNull(oFound)
URL = oFound.String
If InStr(URL, doistring) Then
oFound.HyperlinkName = "DOI"
REM oFound.String = "DOI"
Else
oFound.HyperlinkName = "URL"
End If
oFound.HyperlinkTarget = ""
oFound.HyperlinkURL = URL
oFound = oDocument.findNext(oFound, oSearch)
URL=""
Wend
End Sub