TextToHyperlink delete lock Revision 353338353339 (Sat Jan 28 2012 at 09:27) - Diff Link to this snippet: https://friendpaste.com/1vJ7IguEWBfVakYkVCE5n3 Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 123456789101112131415161718192021222324252627282930313233Sub 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 SelectEnd SubSub RangeReplaceHyperlink(ByVal address) sheet = ThisComponent.Sheets(address.Sheet) For x = address.StartColumn To address.EndColumn For y = address.StartRow To address.EndRow cell = sheet.getCellByPosition(x, y) If (cell.String = "") Then Exit For End If ReplaceHyperlink(cell) Next NextEnd SubSub ReplaceHyperlink(ByVal cell) 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