[Solved] Calling date picker "Calendar for Calc" from Basic

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
DatFrame
Posts: 10
Joined: Mon Feb 20, 2017 10:39 pm

[Solved] Calling date picker "Calendar for Calc" from Basic

Post by DatFrame »

There is a great add-on available here: https://extensions.openoffice.org/en/pr ... endar-calc that will pop up a nicely formatted calendar date picker when in a calc spreadsheet, and double clicking on a date in the calendar will paste the date into whatever cell you have selected. The issue I am having is that it will only run if you select it via Tools -> Add-Ons -> Calendar, OR if you use the keyboard shortcut Ctrl+Shift+F2. I want to call it from a Basic macro.

I looked at how the Calendar add-on is called through the keyboard shortcut by going to Tools -> Customize -> Keyboard and scrolling down to the Ctrl+Shift+F2 Shortcut Keys entry. Beside the entry I see "service:vnd.pycalendar?execute". This is not in a script URL I recognize, or any that I can see from OO documentation https://wiki.openoffice.org/wiki/Docume ... cification or forum posts... Anyone have any ideas on how I could call this from a Basic Macro?

Additional Info: I am attempting to modify the code provided by Charlie Young here viewtopic.php?f=45&t=33842?#p155444 so that a double-click event will call the Calendar add on as I have described above.
Last edited by DatFrame on Thu Aug 10, 2017 12:53 am, edited 1 time in total.
LibreOffice 5.2 on Windows 10
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: Calling date picker "Calendar for Calc" from Basic macro

Post by hubert lambert »

Hello,

You need to instantiate the service with its implementation name:

Code: Select all

calendar = CreateUnoService("vnd.pycalendar")
then call its trigger method with the given argument:

Code: Select all

calendar.trigger("execute")
DatFrame wrote:Additional Info: I am attempting to modify the code provided by Charlie Young here viewtopic.php?f=45&t=33842?#p155444 so that a double-click event will call the Calendar add on as I have described above.
Note that, since 2010, Calc provides direct access to some sheet events, like double click. Right-click the sheet tab -> Sheet Events...
Regards.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Calling date picker "Calendar for Calc" from Basic macro

Post by JeJe »

If you want one that you can modify/develop with Basic - I wrote one in that - calendars are fairly easy to write.

viewtopic.php?f=21&t=86202
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
DatFrame
Posts: 10
Joined: Mon Feb 20, 2017 10:39 pm

Re: Calling date picker "Calendar for Calc" from Basic macro

Post by DatFrame »

hubert lambert and JeJe to the rescue again! Both of your solutions are excellent, I tried them both out and will be posting a final response to conclude the topic later today when I have a little more time to respond, INCLUDING marking the post as SOLVED as both options you two provided solve my issue.

Until later, and thanks again!
LibreOffice 5.2 on Windows 10
DatFrame
Posts: 10
Joined: Mon Feb 20, 2017 10:39 pm

Re: [SOLVED] Calling date picker "Calendar for Calc" from Ba

Post by DatFrame »

Now that I have a little more time, let me just make some remarks about the solutions above:

The code provided by hubert lambert to call the vnd.pycalendar service works perfectly. Just paste those two lines of code in whatever event you want, and as long as the active window is a spreadsheet document you will have no issues. Also, I confirmed that i can use the "Sheet Events" menu to link a macro to the "Double Click" event and it works as expected, I am still going to use the code I referenced before provided by Charlie Young as I have a spreadsheet with multiple sheets in it, and I already have an onOpen event that loads some other listeners and configures a few things.

I ended up going with JeJe's calendar date picker, as I would much rather incorporate another BASIC module into my existing BASIC extension, rather than have to install the python based "Calendar for Calc" on every computer my extension is used on. I have some comments about how I incorporated JeJe's code into my own that may benefit anyone else trying to use it, but I will make those comments on JeJe's original post for it: viewtopic.php?f=21&t=86202

Thanks again for the quick and valuable replies!
LibreOffice 5.2 on Windows 10
sajnoor
Posts: 21
Joined: Fri Nov 09, 2018 2:35 pm

Re: [Solved] Calling date picker "Calendar for Calc" from Ba

Post by sajnoor »

sorry to open old thread but i need some help with calendar i have installed add on and it works using shift + control + f2 or from tools add on how do i automate this so when row b is clicked calendar comes up i see some of you have used some script to do this ?
Openoffice 4.1.5, windows 7 64 bit
sajnoor
Posts: 21
Joined: Fri Nov 09, 2018 2:35 pm

Re: [Solved] Calling date picker "Calendar for Calc" from Ba

Post by sajnoor »

anyone ?
Openoffice 4.1.5, windows 7 64 bit
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Solved] Calling date picker "Calendar for Calc" from Ba

Post by Zizi64 »

I think, you need use some listeners for launching the python extension when you click on a specific column.
https://wiki.openoffice.org/wiki/Docume ... /Listeners
viewtopic.php?f=20&t=74430
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply