Scripting

Libre Office Make Hyperlinks

This allows you to change all links in a selection/sheet to ctrl+click hyperlinks.,

Go to Tools > Macros > Organise Macros and then paste the code in

'––––––––––––––––––––––––––––––––– 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