Page 1 of 1

[Solved] Closing form with macro

Posted: Mon Mar 02, 2009 12:49 am
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

Re: closing form with macro

Posted: Mon Mar 02, 2009 2:58 am
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.

Re: closing form with macro

Posted: Mon Mar 02, 2009 9:06 am
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