Insert a comment with custom presets

    From The Document Foundation Wiki
    < Macros‎ | Writer


    Insert a image in current cursor position in a current document.

    Basic code

    Sub insert_image_in_current_position()
        path_image = "/home/mau/Pictures/pymacros.jpg"
        doc = ThisComponent
        text = doc.CurrentSelection.getByIndex(0).End
        image = doc.createInstance("")
        image.GraphicURL = ConvertToURL(path_image)
        image.AnchorType =
        image.Width = 2500
        image.Height = 2500
        cursor = doc.Text.createTextCursorByRange(text)
        doc.Text.insertTextContent(cursor, image, False)
    End Sub

    References to API