| View previous topic :: View next topic |
| Author |
Message |
dniezby OOo Enthusiast


Joined: 01 May 2004 Posts: 102
|
Posted: Fri Feb 04, 2005 10:59 pm Post subject: Need Macro to Open a Form |
|
|
I'm working with BASE and I was building a Main Menu page to find out, that there doesn't seem to be a way to make the BUTTON I created open up a Form from the database?
Anyone have or know how to create a Macro to open a form? |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Mon Feb 07, 2005 7:39 am Post subject: |
|
|
I have also been unable to open a form from a Base document using a Macro. I can obtain the Form from a database, but I do not know how to display it.... Frank probably knows how to do it, but I only see him post on the dev mailing list. If you find an answer on your own, please post the answer here as well. _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
Rockj Newbie

Joined: 31 Jan 2005 Posts: 4
|
Posted: Tue Feb 08, 2005 12:05 am Post subject: Bad sollution but a temporary fix? |
|
|
PS: It's not related to macro's or anything but your atleast able to open up the new forms
PS2: Take note that it's saving it's path in fullpath which is a bad sollution too :/ So I'm currently also searching for another sollution.
[/img] |
|
| Back to top |
|
 |
dniezby OOo Enthusiast


Joined: 01 May 2004 Posts: 102
|
Posted: Fri Feb 11, 2005 8:07 pm Post subject: |
|
|
What about a Macro to Simply open a document MAXIMIZED?
Anyone know how to do that one easily?
At least if I can get the document to open Maximized the form will be properly viewed on most monitors. |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Sat Feb 12, 2005 8:15 pm Post subject: |
|
|
I found out how to do this in the new beta OK, it was not really me... I asked on the dev list. It turns out ..... | Code: | oDatabaseDocument::XFormsSupplier.getForms().loadComponentFromURL(
<relative_form_url> ) |
Had not thought about it... _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
dniezby OOo Enthusiast


Joined: 01 May 2004 Posts: 102
|
Posted: Sun Feb 13, 2005 11:52 am Post subject: |
|
|
See, here is the problem...I'm trying to create a local application not something that would be run over the net. I wouldn't have a URL.
So, this being the case, how would I open a document that's on a local drive???
I 'm new to this type of coding so I'm still learning BUT isn't there a way to write a URL using something like :
| Code: |
%localdirectory%/docs/document_to_open.odb |
So in this command line it would be done this way:
| Code: |
oDatabaseDocument::XFormsSupplier.getForms().loadComponentFromURL(
<"%local%/docs/document_to_open.odb"> |
|
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Mon Feb 14, 2005 7:03 am Post subject: |
|
|
| Quote: | | See, here is the problem...I'm trying to create a local application not something that would be run over the net. I wouldn't have a URL. So, this being the case, how would I open a document that's on a local drive??? |
Umm, well, if it is running over the net then what good is it to access the local drive
I assume that you need to know where your documents are, or you need to have the user select the document in question.
| Quote: | | I 'm new to this type of coding so I'm still learning BUT isn't there a way to write a URL using something like : %localdirectory%/docs/document_to_open.odb |
Read the section titled "Get and set the current directory" in my free macro document.
| Quote: | So in this command line it would be done this way:
oDatabaseDocument::XFormsSupplier.getForms().loadComponentFromURL(
<"%local%/docs/document_to_open.odb"> |
Well, after you open your database document, and you may have to do this from the connection, I have not tried this.... so, I do not know yet if it is oDoc.getForms.loadComponentFromURL() or if it is oCon.getForms.loadComponentFromURL(), but it should be a simple test fo find out. I have just not gotten that far with my database experiments. _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
dniezby OOo Enthusiast


Joined: 01 May 2004 Posts: 102
|
Posted: Mon Feb 14, 2005 8:14 am Post subject: |
|
|
I have your ebook and I'm looking through it. Thanks.
I wonder...do you think that it's possible to make a stand-alone application using macros? |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Tue Feb 15, 2005 8:46 am Post subject: |
|
|
My ebook? do you mean OpenOffice.org Macros Explained or AndrewMacro? Just curious....
Realize OOo macros run from inside of OpenOffice.org. I am not aware of any way to package these as a stand alone runtime. Also, programs that manipulate the OOo API connect to a running OOo server. _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Tue Feb 15, 2005 12:33 pm Post subject: |
|
|
dniezby:
No, because object files are generated internally (buried into OpenOffice).
As Andrew said OpenOffice acts as the server and there is currently no way to convert OOo macros into stand-alone programs.
But I wonder why you would wanna do that? Starbasic is not that much different from VisualBasic but does not have that much OS (MS Windows respectively) power than VB, or in other words: It's not that general, because it only runs along with OOo.
On the other hand VB is not that general as well, because of no support for other platforms than Microsoft Windows, so Python or Perl might be strongly considered if you want to target multiple platforms and do some easy programming.
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
Iannz OOo Advocate

Joined: 14 Feb 2004 Posts: 494 Location: Christchurch, New Zealand
|
Posted: Tue Feb 15, 2005 7:02 pm Post subject: |
|
|
There are probably better ways of doing things than this but the code below appears to work. I haven't yet looked into how to change the records displayed.
What I am not sure about is where to put the code. I can put it into a library associated with the OOo installation BUT to me it would make more sense if it was in the .odb file. I can't see how to have a library directly associated with a .odb file (only checked the UI) and libraries in forms don't appear to get saved (OOo1.9.77 for Linux).
| Code: |
sub subDisplayForm(sDatabaseName as string, sFormName as string)
dim mArgs(1) as new com.sun.star.beans.PropertyValue
oDatabase = fnGetOpenDatabase(sdatabaseName)
oConnection = oDatabase.getConnection("","")
mArgs(0).name = "OpenMode"
mArgs(0).value = "open" '"openDesign" ' '"openForMail"
mArgs(1).name = "ActiveConnection"
mArgs(1).value = oConnection
oForm = oDatabase.getFormDocuments.getByName(sFormName)
'oForm.visibilityChanged(true)
oDatabase.getFormDocuments.loadComponentFromURL(sFormName, _
"_blank", 0, mArgs())
end sub
function fnGetOpenDatabase(sDatabaseName as string)
oEnum = StarDesktop.getComponents.createEnumeration
while oEnum.hasMoreElements
oPosDB = oEnum.nextElement
if oPosDB.implementationName = "com.sun.star.comp.dba.ODatabaseSource" then
if right(oPosDB.name, len(sDatabaseName)) = sDatabaseName then
fnGetOpenDatabase = oPosDB
exit function
end if
end if
wend
end function |
_________________ Cheers, Ian
http://wiki.services.openoffice.org/wiki/Extensions_development_basic a wiki about writing OpenOffice.org extensions. |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Tue Feb 15, 2005 9:26 pm Post subject: |
|
|
| Quote: | | I can't see how to have a library directly associated with a .odb file |
You can not!... See http://qa.openoffice.org/issues/show_bug.cgi?id=40711 One thing that was said....
| Quote: | a database document does not allow for scripting - you cannot embed macros in
it, so where would you expect "thisComponent" to be useful?
What you can do is embed macros in the forms/reports within a database document.
In those macros, "thisComponent" refers to the form/report itself, which does
make sense. Currently, there is no possibility to access the database document
within such macros, but this is fixed by issue 40358. |
_________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
nimo General User


Joined: 15 Feb 2005 Posts: 10 Location: Netherlands
|
Posted: Wed Feb 16, 2005 1:37 am Post subject: |
|
|
i'm also looking for a way to open new Forms with a button,
so is that the code i need to have? |
|
| Back to top |
|
 |
evershade General User

Joined: 03 May 2004 Posts: 24
|
Posted: Sat Mar 12, 2005 10:08 pm Post subject: open form programmatically in 2.0 |
|
|
lannz,
your method seemed to work at first. but now the form window opens for a blink and then it's gone again. also, 2.0 has taken to crashing after a few attempts.
it's... almost... there...
:o) |
|
| Back to top |
|
 |
evershade General User

Joined: 03 May 2004 Posts: 24
|
Posted: Mon Mar 14, 2005 5:21 pm Post subject: |
|
|
tried creating a new database and encountered similar behavour. the code worked to open a form the first few times but then i get one of the following:
- the form window opens for a split second, then closes
- 2.0 crashes entirely
if i place a breakpoint on or before the line:
| Code: | oDatabase.getFormDocuments.loadComponentFromURL(sFormName, _
"_blank", 0, mArgs()) |
and step thru one line at a time, the form window will stay open until i reach the 'end sub' statement and then close. it appears the form is somehow cotained in the subs memory space and then wiped out upon completion. |
|
| Back to top |
|
 |
|