[Solved] Closing form with macro

Creating and using forms
Post Reply
gtv625
Posts: 18
Joined: Mon Dec 15, 2008 4:16 pm
Location: Kukljica, Croatia

[Solved] Closing form with macro

Post by gtv625 »

to close a form i can use this macro created by Voobase http://user.services.openoffice.org/en/ ... cro#p64519
and it is realy closing the selected form but i can't open that form until i restart OOo. is there a solution to close a form by macro and than in some other time to open it without restarting OOo.

Code: Select all

Sub Close_Form_Button

   Dim oForm As Object

   Rem... This component hack
   oForm = thisComponent.Parent.FormDocuments  
   if oForm.HasByName("FormName") then     
      oForm = oForm.getByName("FormName")
      if not IsNull(oForm.Component) then
        oForm = oForm.Component.DrawPage.Forms.getByName("MainForm")
      End if
   Else
   msgbox "Form Not Found"
   End if

  oForm.parent.parent.CurrentController.Frame.close( true ) Rem... this way so dosen't close wrong form because of timing.
  'thisComponent.CurrentController.Frame.close( true ) Rem.. This line commented out. Could close wrong form if you clicked to another too quickly
  
End Sub
Last edited by gtv625 on Mon Mar 02, 2009 9:06 am, edited 1 time in total.
OOo 3.0.X on Ms Windows XP
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: closing form with macro

Post by Villeroy »

Open the form in edit mode.
Insert>Hyperlink...
URL: .uno:CloseDoc
or create a button with action "Open URL" and the above URL.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
gtv625
Posts: 18
Joined: Mon Dec 15, 2008 4:16 pm
Location: Kukljica, Croatia

Re: closing form with macro

Post by gtv625 »

hi Villeroy,
thank You for wasting your time with me, it's shame i didn't even try your solution from that post

vanja
OOo 3.0.X on Ms Windows XP
Post Reply