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

Creating a macro - Writing a Script - Using the API

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

Postby DatFrame » Wed Aug 09, 2017 1:00 am

There is a great add-on available here: https://extensions.openoffice.org/en/project/calendar-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/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification 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 https://forum.openoffice.org/en/forum/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
DatFrame
 
Posts: 10
Joined: Mon Feb 20, 2017 10:39 pm

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

Postby hubert lambert » Wed Aug 09, 2017 8:43 am

Hello,

You need to instantiate the service with its implementation name:
Code: Select all   Expand viewCollapse view
calendar = CreateUnoService("vnd.pycalendar")

then call its trigger method with the given argument:
Code: Select all   Expand viewCollapse view
calendar.trigger("execute")

DatFrame wrote:Additional Info: I am attempting to modify the code provided by Charlie Young here https://forum.openoffice.org/en/forum/v ... 2?#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
hubert lambert
 
Posts: 59
Joined: Mon Jun 13, 2016 10:50 am

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

Postby JeJe » Wed Aug 09, 2017 10:30 am

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

https://forum.openoffice.org/en/forum/v ... 21&t=86202
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 122
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby DatFrame » Wed Aug 09, 2017 5:27 pm

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

Postby DatFrame » Thu Aug 10, 2017 1:02 am

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: https://forum.openoffice.org/en/forum/viewtopic.php?f=21&t=86202

Thanks again for the quick and valuable replies!
LibreOffice 5.2 on Windows 10
DatFrame
 
Posts: 10
Joined: Mon Feb 20, 2017 10:39 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: robleyd, tiendatanduin and 11 guests