Roberto Crosio wrote:

> Forse ho risolto, ma ditemelo voi, per favore...

Questa è la risposta in inglese di Lionel:

> The macro "EsciDabase" produces the following error with LibreOffice 3.5:
> Errore di runtime BASIC.
> Si è verificata un'eccezione
> Type: com.sun.star.container.NoSuchElementException

It produces the same error with LibreOffice 3.3.3; I'm fairly sure it
*never* worked with *any* version of Open/LibreOffice. This macro
shows its author confused the notion of a form and of the controls
contained in it. Here's a version that is probably what the author
intended:

Sub EsciDaBase
    Dim oForms as Object, oForm as Object
    oForms = ThisComponent.DrawPage.Forms
    oForm = oForms.GetByName("Formulario")
    oForm.ActiveConnection.flush()
    StarDesktop.terminate
End sub

I just replaced "Uscita" by "Formulario" in the GetByName
call. Formulario is the name of the form and Uscita is the name of the
button in the form. I recommend the user use the "Form navigator" (in
the Form design toolbar) to understand their relationship.

Anyway, this looks to me like it tries to close the whole of
LibreOffice, including any other document opened in it (Writer
document, Calc spreadsheet, Impress presentation, ...). That is
definitely not good practise!

Here is my version of EsciDaBase:

Sub EsciDaBase
    ThisDatabaseDocument.close(False)
End sub

You can also use

Sub EsciDaBase
    ThisDatabaseDocument.CurrentController.Frame.close(False)
End sub

The user will probably want something like:

Sub EsciDaBase
    Dim oForms as Object, oForm as Object
    oForms = ThisComponent.DrawPage.Forms
    oForm = oForms.GetByName("Formulario")
    oForm.ActiveConnection.flush()
    ThisDatabaseDocument.close(False)
End sub

ThisDatabaseDocument is new in OpenOffice 3.0; if compatibility with
older versions is needed, then start from thisComponent, get its
parent's parent's parent's ... parent, until one gets a
com.sun.star.comp.dba.ODatabaseDocument.

You may have noticed I pass "False" instead of "True" to the close()
method/procedure. Passing "True" crashes LibreOffice; that may be a
real bug; to be tested if it also crashes LibreOffice 3.5. Anyway, my
feeling is that "False" is the right choice anyway.

-- 
Italo Vignoli - italo.vign...@gmail.com
mob +39.348.5653829 - VoIP 5316...@messagenet.it
skype italovignoli - gtalk italo.vign...@gmail.com

-- 
Come cancellarsi: E-mail users+h...@it.libreoffice.org
Problemi? http://it.libreoffice.org/supporto/mailing-lists/come-cancellarsi/
Linee guida per postare + altro: 
http://wiki.documentfoundation.org/Local_Mailing_Lists/it
Archivio della lista: http://listarchives.libreoffice.org/it/users/
Tutti i messaggi inviati a questa lista vengono archiviati pubblicamente e non 
sono eliminabili

Rispondere a