[Solved] Open a form from a macro
Posted: Fri Feb 15, 2008 5:55 pm
I've tried to do this using code examples from many forums, but I always get an error message. Here's my latest effort:
I assign this macro to the "Mouse button released" event of a button on a dialog. However, when I run the dialog and click the button, I get a Basic runtime error: "Property or method not found.", pointing to the line "Form = Event.Source.Model.Parent ".
Can someone tell me what I'm doing wrong?
Thanks,
David
Code: Select all
Sub OpenForm(Event As Object)
Dim Form As Object
Dim FormDoc AS Object
Dim FormCollection As Object
Dim DBDoc As Object
Dim Args(1) As New com.sun.star.beans.PropertyValue
Form = Event.Source.Model.Parent
FormCollection=Form.Parent
FormDoc=FormCollection.Parent
DBDoc=FormDoc.Parent
Args(0).Name="ActiveConnection"
Args(0).Value=Form.ActiveConnection
Args(1).Name="OpenMode"
Args(1).Value="open"
DBDoc.FormDocuments.loadComponentFromURL("NewFormDisplay","_blank",0,Args())
End Sub
Can someone tell me what I'm doing wrong?
Thanks,
David