Page 1 of 1

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

Posted: Wed Aug 09, 2017 1:00 am
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.

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

Posted: Wed Aug 09, 2017 8:43 am
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.

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

Posted: Wed Aug 09, 2017 10:30 am
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

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

Posted: Wed Aug 09, 2017 5:27 pm
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!

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

Posted: Thu Aug 10, 2017 1:02 am
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!

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

Posted: Mon Nov 12, 2018 12:14 pm
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 ?

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

Posted: Sat Nov 17, 2018 1:56 am
by sajnoor
anyone ?

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

Posted: Sat Nov 17, 2018 2:02 pm
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