Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


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.vignoli@gmail.com
mob +39.348.5653829 - VoIP 5316436@messagenet.it
skype italovignoli - gtalk italo.vignoli@gmail.com

-- 
Come cancellarsi: E-mail users+help@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

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.