[Solved] Close Form after pressing button

Creating a macro - Writing a Script - Using the API

[Solved] Close Form after pressing button

Postby DreamerArgentino » Mon Dec 03, 2018 5:29 pm

Hi all.
I have this code to open a Form from a switchboard, and I would like to press it, execute two actions, the current one and also close the switchboard.

I hope you can help me. Thank you!
------------------------------------------------------------------------------------------------------------------------------------
Code: Select all   Expand viewCollapse view
REM  *****  BASIC  *****

Sub OpenForm1 (oEvent as object)

const sNewDocumentName="FRM-Students01"     '"FRM-Students"

'If Not Globalscope.BasicLibraries.isLibraryLoaded("MRILib") Then
'      Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
'End If
'Dim oMRI as object
'oMRI = CreateUnoService( "mytools.Mri" )


oDoc = ThisDatabaseDocument
'oMRI.inspect oEvent
oForm = oEvent.Source.Model.Parent  'get form from event
'oMRI.inspect oForm
oForm.updateRow  'save selection

oNewFormDocument=oDoc.FormDocuments.getbyname(sNewDocumentName).open
End Sub

Sub Macro1

End Sub
Last edited by robleyd on Wed Dec 05, 2018 12:52 am, edited 2 times in total.
Reason: Added Code tags
OpenOffice 4.1.5 On Windows 10
DreamerArgentino
 
Posts: 17
Joined: Sun May 20, 2018 12:02 am

Re: Close Form after pressing button

Postby UnklDonald418 » Mon Dec 03, 2018 8:41 pm

To close the switchboard you can add a line to your macro
Code: Select all   Expand viewCollapse view
oDoc.FormDocuments.getbyname("Initial-Switchboard").close

however, because you have made changes to the form document by making a selection you will get a dialog asking if you want to save your changes.
To avoid the dialog you can use:
Code: Select all   Expand viewCollapse view
oDoc.FormDocuments.getbyname("Initial-Switchboard").dispose
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.7 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1279
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Close Form after pressing button

Postby DreamerArgentino » Tue Dec 04, 2018 2:51 pm

Excellent!!! Thank you UnklDonald418!!!
OpenOffice 4.1.5 On Windows 10
DreamerArgentino
 
Posts: 17
Joined: Sun May 20, 2018 12:02 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests