Joined: Jun 20, 2006 Posts: 2051 Location: Midwest, USA
Posted: Mon Sep 24, 2007 5:14 pm Post subject: Macro to open a Form
In working on creating my birding database and writing a tutorial for it, I decided to add a button on one form to open another form.
I did some checking in the OOo Base forum, and found this thread.
To my knowledge, all I changed was the name of the form, but I can't get the macro to work. I get a "too many paramters" error.
I asked a followup question in the thread, but have not received any replies. I know we don't have much depth with Base here, but I'm hoping that one of our macro gurus can help me out.
here's the code as I have modified it:
Code:
REM Generic macros needed to open any form
function OpenForm( formContainer as variant, oConnection as variant, sFormName as string) as variant
Dim aProp(1) As New com.sun.star.beans.PropertyValue
aProp(0).Name = "ActiveConnection"
aProp(0).Value = oConnection
aProp(1).Name = "OpenMode"
aProp(1).Value = "open"
OpenForm = formContainer.loadComponentFromURL(sFormName,"_blank",0,aProp())
end function
function getFormsTC() as variant
getFormsTC = thisComponent.Parent.getFormDocuments
end function
function getConnectionTC() as variant
getConnectionTC = thisComponent.Drawpage.Forms(0).ActiveConnection
end function
REM Macro to open specific form called 'Locations Data Entry'. One is needed for each form you wish to open from another form.
sub OpenForm_Locations_Data_Entry( oev as variant )
sFormName = "Locations Data Entry"
OpenForm( getFormsTC, getConnectionTC, sFormName )
end sub
Joined: Jun 20, 2006 Posts: 2051 Location: Midwest, USA
Posted: Wed Oct 03, 2007 7:07 pm Post subject:
I asked in the OOo Macro forum and found my problem: I was testing the macro by choosing Tools>Macros>Run Macros. If I create a button in a form and assign the macro to it, it works perfectly.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum