Wow, I think I found solution in other topic:
Here is the macro:
'––––––––––––––––––––––––––––––––– Hyperlinks ––––––––––––––––––––––––––––––––––
Sub SelectionInsertHyperlink()
Dim oSelection As Object: oSelection = ThisComponent.CurrentSelection
If Not (oSelection.supportsService("com.sun.star.sheet.SheetCellRange") _
Or oSelection.supportsService("com.sun.star.sheet.SheetCellRanges")) Then
MsgBox "The range is not selected. Multiple selection is allowed." _
, MB_ICONEXCLAMATION, "Selection Error"
Exit Sub
End If
Call ActiveSheetInsertHyperlink(oSelection)
End Sub
Sub ActiveSheetInsertHyperlink(Optional oSelection)
Dim oRanges As Object, oCell As Object
If IsMissing(oSelection) Then
oRanges = ThisComponent.CurrentController.ActiveSheet _
.queryContentCells(com.sun.star.sheet.CellFlags.STRING)
Else
oRanges = oSelection.queryVisibleCells() 'visible only
End If
For Each oCell In oRanges.Cells
Call CellInsertHyperLink(oCell)
Next
End Sub
Sub CellInsertHyperLink(oCell As Object)
''' Remarks:
''' • oCell.Text.insertTextContent(xRange, xContent, bAbsorb)
''' <xRange> specifies the position of insertion.
''' <xContent> is the text content to be inserted.
''' <bAbsorb> specifies whether the text spanned by xRange will be replaced.
''' • If True then the content of xRange will be replaced by xContent,
''' otherwise xContent will be inserted at the end of xRange.
Dim oField As Object
Dim s As String, i As Integer
oField = ThisComponent.createInstance("com.sun.star.text.TextField.URL")
Rem Xray oField 'ScEditFieldObj
s = oCell.String
i = InStr(1, s, "http")
If i > 0 Then
oCell.String = Left(s, i - 1)
oField.URL = Mid(s, i)
oField.Representation = oField.URL
oCell.Text.insertTextContent(oCell.Text.createTextCursor, oField, False)
End If
End Sub
When I pasted it into some blank macro, and run in the document, ALL text links changed into hyperlinks. Didn’t have to mark rows or columns, or text. Just one time run in a document and it’s done. It even works better the previous macro I used!
Still, libreoffice should make it a tool to mark and click, to turn text links into hyperlinks. It boggles my mind that it is not a standard, and we need to look for macros to do that simple and basic action.