Insert a comment with custom presets

From The Document Foundation Wiki
< Macros‎ | Writer
Jump to navigation Jump to search


Description

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

Basic code

 1Sub insert_in_cursor_position()
 2    data = "Hello World with Basic"
 3
 4    REM Current document
 5    doc = ThisComponent
 6
 7    REM Current selection always return a ranges, and get to end
 8    text = doc.CurrentSelection.getByIndex(0).End
 9    
10    REM Write data
11    text.String = data    
12End Sub

References to API

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