Opening "spelling and grammar dialog" from BASIC script

Hi.

I’ve been struggeling for a while on a simple script : opening the spell check, and (as soon as the dialog is closed),
from a script, save, and close the document.

Pretty much like this, in MSOffice’s BASIC
(I’m trying to get rid of it, and spending a few days in translating scripts into LO’s) :
Application.Dialogs(wdDialogToolsSpellingAndGrammar).Show
Application.Quit SaveChanges:=True

First try with a macro recorder gave me something like that :
dispatcher.execute(document, ".uno:SpellingAndGrammarDialog", "", 0, Array())
dispatcher.execute(document, ".uno:Save", "", 0, Array())
dispatcher.execute(document, ".uno:Close", "", 0, Array())

But the dispatcher seems to launch everyting on a separate thread.
The “Spell” and “Save” seems to be interrupted by the “Close”.
dispatcher.execute(document, ".uno:SpellingAndGrammarDialog", "", 0, Array())
ThisComponent.store()
ThisComponent.close(True)
Now the “Save” and “Close” are synchronized, but the SpellCheck doesn’t have time to pop up.

So, the question(s) :
Is there a non-dispatcher way to call the SpellingAndGrammarDialog ?
-OR- Is there a way to wait for a dispatcher task’s end / existing dialog’s closing in BASIC ?

Cheers.

This is way beyond me. But ch. 11 in Andrew Pitonyak’s famous book (scroll to bottom of that page) is all about using the dispatcher. Have you seen it?

Chapter 6 of https://wiki.openoffice.org/w/images/d/d9/DevelopersGuide_OOo3.1.0.pdf might be helpful too.

From Chapter 6 of the Developer’s Guide noted by Regina, it looks like you’d need to implement the XNotifyDispatcher interface and call its dispatchWithNotification method (rather than using the dispatch method) to be able to react when the dispatch is finished. You’d also need to implement XDispatchResultListener to pass as a parameter in dispatchWithNotification. Java’s no prob, but I’m not clear on how to translate this to Basic. Hopefully, someone more skilled in Basic can chime in here…