If you are up to a macro, then the following will convert each cell in the current selection into a hyperlink with the same URL as the cell text itself.
- This code automatically adds https:// to a URL if that is missing. If you don’t want that, simply remove that
If
clause.
- It also sets each hyperlink cell style to the constant style name given in the macro. If you create a style just for hyperlinks then you can change that constant to your new style name. If you want no styling, just remove that line.
Sub Hyperize()
Dim Selection As Object
Dim URL As String
Dim Row As Integer
Dim Column As Integer
Dim Style As String
Style = "Accent" 'Change to, say, "Hyperlink" if you create a specific style for that
Selection = ThisComponent.getCurrentSelection()
If Selection.ImplementationName = "ScCellObj" Then
HyperizeCell(Selection, Style)
ElseIf Selection.ImplementationName = "ScCellRangeObj" Then
For Row = 0 To Selection.Rows.Count - 1
For Column = 0 To Selection.Columns.Count - 1
HyperizeCell(Selection.getCellByPosition(Column,Row), Style)
Next Column
Next Row
Endif
End Sub
Private Sub HyperizeCell(Cell As Object, Style As String)
Dim URL As String
URL = Cell.Text.String
If LCase(Left(URL,8)) <> "https://" Then
URL = "https://" & URL
EndIf
Cell.Text.Hyperlink = URL
Cell.CellStyle = Style 'Remove if no styling wanted
End Sub