Using createUnoService

Hi,

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
Shell("getinvoicea.exe",0,0,1)
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dim args1(0) as new com.sun.star.beans.PropertyValue
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.