Run macro at specific time

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
moka2011
Posts: 2
Joined: Sat Dec 17, 2011 1:53 pm

Run macro at specific time

Post by moka2011 »

How to run macro at specific time in open office.
Thanks!
OpenOffice 3.1 on windows XP
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Run macro at specific time

Post by JohnSUN-Pensioner »

Welcome to forum!
This macro should be able to show a Christmas card? ;-)
Try to set a standard system scheduler string of the form

Code: Select all

<Full path>\soffice.exe macro:///<name of the library>.<the module name>.<procedure name>([parameter1[, parameter2 ...]])
For example

Code: Select all

C:\PROGRA~1\LIBREO~1.4\program\soffice.exe  macro:///XLS_TO_PDF.copySheetsToOneBook.CopyLastSheetHere(C:\tmp\old.xls,C:\tmp\new.ods)
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
kingfisher
Volunteer
Posts: 2123
Joined: Tue Nov 20, 2007 10:53 am

Re: Run macro at specific time

Post by kingfisher »

If you mean nominate a time (or, more accurately, an event) when the macro runs, use Tools > Macros > Organise macros > Basic | etc. In the dialogue that appears, select the macro you want to open at a particular point, and press 'Assign'. In the next dialogue, look at the 'Events' tab and select the event you want.
Apache OpenOffice 4.1.9 on Linux
moka2011
Posts: 2
Joined: Sat Dec 17, 2011 1:53 pm

Re: Run macro at specific time

Post by moka2011 »

Thanks! But what i've ment was that i need a macro to run at specific time. Like on 11pm, everyday. I want to setup a macro to save the active opened document and close it.
I've done this in excel 2003 and it works, but the VB script won't work in open office.
The script is as:
Sub close()

Application.OnTime

TimeValue ("09:00:00"), "close"
'
' close Macro
'
' Keyboard Shortcut: Ctrl+m
'
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub

Thanks for help!
OpenOffice 3.1 on windows XP
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Run macro at specific time

Post by rudolfo »

How did you save this kind of macro in Excel? As far as I can see this macro must be saved somewhere in the general Excel settings and can't be saved in a normal working document, because you can never know which document will be open at the time when the macro runs.
And if it is in the general settings it can as well be stored in your user's home directory of the OS. Or as JohnSUN-Pensioner has put it in the task scheduler of Windows XP as a command line that should be executed at a certain time. A quick google search gave me this: How To Schedule Tasks in Windows XP
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
Post Reply