Run macro at specific time

Creating a macro - Writing a Script - Using the API

Run macro at specific time

Postby moka2011 » Sat Dec 17, 2011 1:56 pm

How to run macro at specific time in open office.
Thanks!
OpenOffice 3.1 on windows XP
moka2011
 
Posts: 2
Joined: Sat Dec 17, 2011 1:53 pm

Re: Run macro at specific time

Postby JohnSUN-Pensioner » Sat Dec 17, 2011 3:14 pm

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   Expand viewCollapse view
<Full path>\soffice.exe macro:///<name of the library>.<the module name>.<procedure name>([parameter1[, parameter2 ...]])
For example
Code: Select all   Expand viewCollapse view
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.4, LibreOffice 5.4.2.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 761
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Run macro at specific time

Postby kingfisher » Sun Dec 18, 2011 6:00 am

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.6 on PCLinuxOS
User avatar
kingfisher
Volunteer
 
Posts: 2120
Joined: Tue Nov 20, 2007 10:53 am

Re: Run macro at specific time

Postby moka2011 » Mon Dec 19, 2011 12:32 pm

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
moka2011
 
Posts: 2
Joined: Sat Dec 17, 2011 1:53 pm

Re: Run macro at specific time

Postby rudolfo » Mon Dec 19, 2011 1:33 pm

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.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests