Jump to content

Insert a comment with custom presets

From The Document Foundation Wiki


Description

Insert a string in the cursor position in a current document.

Basic code

Sub insert_in_cursor_position()
    data = "Hello World with Basic"

    REM Current document
    doc = ThisComponent

    REM Current selection always return a ranges, and get to end
    text = doc.CurrentSelection.getByIndex(0).End
    
    REM Write data
    text.String = data    
End Sub


References to API

Line Link
5 com.sun.star.text.TextDocument
8, 11 com.sun.star.text.XTextRange