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