TextToHyperlink delete lock Revision 336637613362 (Tue Jan 31 2012 at 03:59) - 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 12345678910111213141516171819202122232425262728293031323334353637383940Sub TextToHyperlink() selection = ThisComponent.CurrentSelection Select Case (selection.ImplementationName) Case "ScCellObj" If (selection.String = "") Then Exit Sub End If 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 If (y = address.StartRow) Then Exit Sub Else Exit For End If 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