Using createUnoService


I have an external program that fetches the current invoice number from a file and copies it to the clipboard (in this case GetInvoiceA). I wrote a macro to call the program and paste the invoice number to the current cell:

Sub GetInvoice
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("")

dim args1(0) as new
args1(0).Name = "Format"
args1(0).Value = 1

dispatcher.executeDispatch(document, ".uno:Paste", "", 0, args1())

End Sub

Everything seems to work fine which has me a bit paranoid as usual. I’m not at all familiar with BASIC, preferring C or Assembler, so what I need to know is if once I create an instance of UnoService do I need to destroy the instance when I’m done to prevent memory leaks or is that handled internally ?

You don’t have to change anything. Once you exited it is gone. It is just a variable of type Object.