TextToHyperlink delete lock Revision 656331373462 (Sat Jan 28 2012 at 07:37) - 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 1234567891011121314151617181920212223242526272829303132Sub 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 Sub2Sub 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 NextEnd SubSub 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