--- Revision None +++ Revision 363935623035 @@ -0,0 +1,32 @@ +Sub TextToHyperlink() + selection = ThisComponent.CurrentSelection + Select Case (selection.ImplementationName) + Case "ScCellObj" + ReplaceHyperlink(selection) + Case "ScCellRangeObj" + RangeReplaceHyperlink(selection.RangeAddress) + Case "ScCellRangesObj" + For Each address In selection.RangeAddresses + RangeReplaceHyperlink(address) + Next + End Select +End Sub + +Sub RangeReplaceHyperlink(ByVal address) + sheet = ThisComponent.Sheets(address.Sheet) + For y = address.StartRow To address.EndRow + For x = address.StartColumn To address.EndColumn + ReplaceHyperlink(sheet.getCellByPosition(x, y)) + Next + Next +End Sub + +Sub ReplaceHyperlink(ByVal cell) + If (cell.String = "") Then + Exit Sub + End If + hyperlink = ThisComponent.createInstance("com.sun.star.text.TextField.URL") + hyperlink.Representation = cell.String + hyperlink.URL = cell.String + cell.Text.insertTextContent(cell.createTextCursor(), hyperlink, True) +End Sub