I’m able to create a macro that adds text to the current cursor location as follows (excerpt):
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = "Arbitrary text that I want to insert goes here"
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args1())
However, after I run the macro, if I hit Ctrl+Z to undo, only the last word is erased, and each successive Ctrl+Z erases an additional word. So it seems the InsertText operation really acts as though the text was typed in word by word.
What I’d like is the text to be inserted as a single operation such that Ctrl+Z erases all the text that was just inserted through the macro, as though I had added the text by doing Edit>Paste.
How can I do this? Ideally I wouldn’t have to mess up the copy buffer by putting my text in there and then artificially running the Paste command through the macro, but if that’s the only option, I would accept it.