Run macro upon document load

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
NiksaVel
Posts: 91
Joined: Fri Jan 25, 2008 12:00 pm
Location: Croatia

Run macro upon document load

Post by NiksaVel »

Hi all,

I was wondering how I could set up a macro to be executed once when the document is first loaded... ? I want to set the ooBase form to fullscreen when it's opened... I have the macro and it works when mapped to a button, but I'd like it to work automagically :)
OOo 3.1.X on Ubuntu 8.x + Linux Mint 7, Win XP, Vista
User avatar
Hagar Delest
Moderator
Posts: 33400
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Run macro upon document load

Post by Hagar Delest »

Have a look at the Tools>Customize>Events dialog.

Thanks to add '[Solved]' at beginning of your first post title (edit button) if your issue has been fixed.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE Faye) and 24.8 portable on Windows 11.
User avatar
NiksaVel
Posts: 91
Joined: Fri Jan 25, 2008 12:00 pm
Location: Croatia

Re: Run macro upon document load

Post by NiksaVel »

If I understand corrently, this will only work if I have a "stand alone" form saved as a writer document pn the desktop... than I can assign the "maximize to fullscreen" macro to the "open document" and it works... but can I assign this to the forms inside a database?

I have a main "opening" form... and from there I have a lot of buttons which open various other forms inside the same database... I would like to have all of those open in fullscreen...
OOo 3.1.X on Ubuntu 8.x + Linux Mint 7, Win XP, Vista
User avatar
NiksaVel
Posts: 91
Joined: Fri Jan 25, 2008 12:00 pm
Location: Croatia

Re: Run macro upon document load

Post by NiksaVel »

I found what appears to be exactly the thing that I'm looking for here:
http://www.oooforum.org/forum/viewtopic.phtml?t=65111
The following macro can be linked to the "when loading"-event in the Form. It will maximize the form to a full screen-form. The macro's after this one are needed too:
But I can't get it to work... I've entered the macro:

Code: Select all

sub onWhenLoading( oEvent as object )
MaximizeFrame( oEvent.Source.Parent.Parent.CurrentController.Frame)
end sub

Declare Function ShowWindow Lib "user32" _
(ByVal lHwnd As Long, _
ByVal lCmdShow As Long) As Boolean

sub MaximizeFrame( aFrame as object )
dim frame
dim window
dim handle
window = aframe.getContainerWindow()
handle = window.getWindowHandle(dimarray(), 1)
REM 1=WIN32
ShowWindow( handle, 3 )
end sub

and I've mapped it to the "when loading" event on the form properties... but nothing is happening... am I doing something wrong here?? Some1 please help out...
OOo 3.1.X on Ubuntu 8.x + Linux Mint 7, Win XP, Vista
Post Reply