How can I insert text from the clipboard and then select it in a macro.

I am cutting and pasting text from another app into LibreOffice Writer. The text can range from one line to maybe 20 paragraphs. I would like to write a macro that would insert the text, select it, remove default formatting and apply a style, but I don’t know how to select the text after inserting it.