I’m having an issue with the default save macro on libre base. It will run when a form is not fully loaded causing an “object variable not set” error.
The original save macro code was:
Sub Save
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)
dispatcher.executeDispatch(document, “.uno:RecSave”, “”, 0, Array())
End Sub
Then I tried to add validation to make sure the form loaded before running the macro but it’s not working. The macro will still run when the form is not loaded:
Sub Save
dim document as object
dim dispatcher as object
dim Loaded as Boolean
Loaded = True
dim oController
oController = ThisDatabaseDocument.CurrentController
if( Not oController.isConnected() ) Then
oController.connect()
Else
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)
dispatcher.executeDispatch(document, “.uno:RecSave”, “”, 0, Array())
End if
End Sub
Please help.