rhubarbpieguy | 19 Jul 23:48 2012
Picon

Date format macro.


I'd like to create a macro for a user-defined date format (H:MMa/p).  As
examples, 7:00 AM would display as 7:00a and 3:33 PM as 3:33p.  I can
create the format manually, but I understand the LibreOffice format
can't save user-defined formats.  So my thought is to create a macro
which creates the format each time the spreadsheet is opened.  The
user-defined Format Code is for a saved Style.

The macro records without incident and the date format is correct.
However, running the saved macro doesn't change the format.  It seems
this should work.  Thoughts?  The recorded macro is as follows:

sub FormatTime
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$D$13"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------
(Continue reading)

Dave Barton | 20 Jul 09:16 2012
Picon

Re: Date format macro.

-------- Original Message  --------
From: rhubarbpieguy <at> gmail.com
To: users <at> global.libreoffice.org
Date: Thu, 19 Jul 2012 16:48:53 -0500

> 
> I'd like to create a macro for a user-defined date format (H:MMa/p).  As
> examples, 7:00 AM would display as 7:00a and 3:33 PM as 3:33p.  I can
> create the format manually, but I understand the LibreOffice format
> can't save user-defined formats.  So my thought is to create a macro
> which creates the format each time the spreadsheet is opened.  The
> user-defined Format Code is for a saved Style.
> 
> The macro records without incident and the date format is correct.
> However, running the saved macro doesn't change the format.  It seems
> this should work.  Thoughts?  The recorded macro is as follows:
> 
> sub FormatTime
> rem ----------------------------------------------------------------------
> rem define variables
> dim document   as object
> dim dispatcher as object
> rem ----------------------------------------------------------------------
> rem get access to the document
> document   = ThisComponent.CurrentController.Frame
> dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
> 
> rem ----------------------------------------------------------------------
> dim args1(0) as new com.sun.star.beans.PropertyValue
> args1(0).Name = "ToPoint"
(Continue reading)

rhubarbpieguy | 21 Jul 03:33 2012
Picon

Re: Date format macro.

On 07/20/12 02:16, Dave Barton wrote:
> -------- Original Message  --------
> From: rhubarbpieguy <at> gmail.com
> To: users <at> global.libreoffice.org
> Date: Thu, 19 Jul 2012 16:48:53 -0500
>
>> I'd like to create a macro for a user-defined date format (H:MMa/p).  As
>> examples, 7:00 AM would display as 7:00a and 3:33 PM as 3:33p.  I can
>> create the format manually, but I understand the LibreOffice format
>> can't save user-defined formats.  So my thought is to create a macro
>> which creates the format each time the spreadsheet is opened.  The
>> user-defined Format Code is for a saved Style.
>>
>> The macro records without incident and the date format is correct.
>> However, running the saved macro doesn't change the format.  It seems
>> this should work.  Thoughts?  The recorded macro is as follows:
>>
>> sub FormatTime
>> rem ----------------------------------------------------------------------
>> rem define variables
>> dim document   as object
>> dim dispatcher as object
>> rem ----------------------------------------------------------------------
>> rem get access to the document
>> document   = ThisComponent.CurrentController.Frame
>> dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
>>
>> rem ----------------------------------------------------------------------
>> dim args1(0) as new com.sun.star.beans.PropertyValue
>> args1(0).Name = "ToPoint"
(Continue reading)

Dave Barton | 21 Jul 07:45 2012
Picon

Re: Date format macro.

-------- Original Message  --------
From: rhubarbpieguy <at> gmail.com
To: users <at> global.libreoffice.org
Date: Fri, 20 Jul 2012 20:33:27 -0500

> On 07/20/12 02:16, Dave Barton wrote:
>> -------- Original Message  --------
>> From: rhubarbpieguy <at> gmail.com
>> To: users <at> global.libreoffice.org
>> Date: Thu, 19 Jul 2012 16:48:53 -0500
>>
>>> I'd like to create a macro for a user-defined date format (H:MMa/p).  As
>>> examples, 7:00 AM would display as 7:00a and 3:33 PM as 3:33p.  I can
>>> create the format manually, but I understand the LibreOffice format
>>> can't save user-defined formats.  So my thought is to create a macro
>>> which creates the format each time the spreadsheet is opened.  The
>>> user-defined Format Code is for a saved Style.
>>>
>>> The macro records without incident and the date format is correct.
>>> However, running the saved macro doesn't change the format.  It seems
>>> this should work.  Thoughts?  The recorded macro is as follows:
>>>
8<-- code snip for brevity -->8
>> Sorry I can't help with your macro, but I like your idea.
>> An alternative approach I use, is to add my user defined date format to
>> my Calc default template.
>>
>> Dave
>>
>>
(Continue reading)

Andreas Säger | 21 Jul 11:15 2012
Picon

Re: Date format macro.


rhubarbpieguy wrote
> 
>>
> Thank you for responding; I admire your style. I manually changed the 
> date format of my spreadsheet, saved , then coded it as the default 
> template. The default template took, but unfortunately, again the 
> user-defined date format wasn't saved.
> 
> 

That would be a severe bug. My default template (including number formats
for many purposes) works as it used to work since OOo 2.

--
View this message in context: http://nabble.documentfoundation.org/Date-format-macro-tp3996521p3996828.html
Sent from the Users mailing list archive at Nabble.com.

Andreas Säger | 20 Jul 09:47 2012
Picon

Re: Date format macro.

Am 19.07.2012 23:48, rhubarbpieguy <at> gmail.com wrote:
  but I understand the LibreOffice format
> can't save user-defined formats.

The entire suite is about customization rather than programming. 
Templates and styles provide most of the productivity features. Macros 
(particularly recorded ones) are a total waste of time.

--

-- 
For unsubscribe instructions e-mail to: users+help <at> global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Pedro | 21 Jul 03:49 2012
Picon

Re: Date format macro.


rhubarbpieguy wrote
> 
> I'd like to create a macro for a user-defined date format (H:MMa/p).  As
> examples, 7:00 AM would display as 7:00a and 3:33 PM as 3:33p.  I can
> create the format manually, but I understand the LibreOffice format
> can't save user-defined formats.  So my thought is to create a macro
> which creates the format each time the spreadsheet is opened.  The
> user-defined Format Code is for a saved Style.
> 

Since this is a limitation of the ODF file format and that modifying the
default template only applies to your PC (correct me if I'm wrong) wouldn't
it make more sense to simply save it as XLS?

I tested with your example and the user-defined time format is saved...

--
Pedro

--
View this message in context: http://nabble.documentfoundation.org/Date-format-macro-tp3996521p3996810.html
Sent from the Users mailing list archive at Nabble.com.

rhubarbpieguy | 21 Jul 16:26 2012
Picon

Re: Re: Date format macro.

On 07/20/12 20:49, Pedro wrote:
> rhubarbpieguy wrote
>> I'd like to create a macro for a user-defined date format (H:MMa/p).  As
>> examples, 7:00 AM would display as 7:00a and 3:33 PM as 3:33p.  I can
>> create the format manually, but I understand the LibreOffice format
>> can't save user-defined formats.  So my thought is to create a macro
>> which creates the format each time the spreadsheet is opened.  The
>> user-defined Format Code is for a saved Style.
>>
> Since this is a limitation of the ODF file format and that modifying the
> default template only applies to your PC (correct me if I'm wrong) wouldn't
> it make more sense to simply save it as XLS?
>
> I tested with your example and the user-defined time format is saved...
>
> --
> Pedro
>
>
>
> --
> View this message in context: http://nabble.documentfoundation.org/Date-format-macro-tp3996521p3996810.html
> Sent from the Users mailing list archive at Nabble.com.
>
Yes, XLS will save the format, but my macros don't carry over.

--

-- 
For unsubscribe instructions e-mail to: users+help <at> global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
(Continue reading)

Andreas Säger | 27 Jul 12:14 2012
Picon

Re: Date format macro.

Am 19.07.2012 23:48, rhubarbpieguy <at> gmail.com wrote:
>
> I'd like to create a macro for a user-defined date format (H:MMa/p).  As
> examples, 7:00 AM would display as 7:00a and 3:33 PM as 3:33p.  I can
> create the format manually, but I understand the LibreOffice format
> can't save user-defined formats.  So my thought is to create a macro
> which creates the format each time the spreadsheet is opened.  The
> user-defined Format Code is for a saved Style.
>
> The macro records without incident and the date format is correct.
> However, running the saved macro doesn't change the format.  It seems
> this should work.  Thoughts?  The recorded macro is as follows:
>

Hello,

The issue is a known one (AOO bug #66842). The office seems to support 
some format codes that have no equivalent expression in the ODF standard.
It has been discussed in a productive manner here:
http://user.services.openoffice.org/en/forum/viewtopic.php?f=9&t=53724
http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=55344

I attached simple Basic macro to a demo document:
http://user.services.openoffice.org/en/forum/download/file.php?id=14598

It links number formats to cell styles so the newly generated number 
formats applies to all the cells where the style is in use.

Hope this helps,
A.S.
(Continue reading)

rhubarbpieguy | 27 Jul 19:32 2012
Picon

Re: Re: Date format macro.

On 07/27/12 05:14, Andreas Säger wrote:
> Am 19.07.2012 23:48, rhubarbpieguy <at> gmail.com wrote:
>>
>> I'd like to create a macro for a user-defined date format (H:MMa/p).  As
>> examples, 7:00 AM would display as 7:00a and 3:33 PM as 3:33p. I can
>> create the format manually, but I understand the LibreOffice format
>> can't save user-defined formats.  So my thought is to create a macro
>> which creates the format each time the spreadsheet is opened. The
>> user-defined Format Code is for a saved Style.
>>
>> The macro records without incident and the date format is correct.
>> However, running the saved macro doesn't change the format.  It seems
>> this should work.  Thoughts?  The recorded macro is as follows:
>>
>
> Hello,
>
> The issue is a known one (AOO bug #66842). The office seems to support 
> some format codes that have no equivalent expression in the ODF standard.
> It has been discussed in a productive manner here:
> http://user.services.openoffice.org/en/forum/viewtopic.php?f=9&t=53724
> http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=55344
>
> I attached simple Basic macro to a demo document:
> http://user.services.openoffice.org/en/forum/download/file.php?id=14598
>
> It links number formats to cell styles so the newly generated number 
> formats applies to all the cells where the style is in use.
>
> Hope this helps,
(Continue reading)

rhubarbpieguy | 28 Jul 00:14 2012
Picon

[Solved] Re: Re: Date format macro.

On 07/27/12 05:14, Andreas Säger wrote:
> Am 19.07.2012 23:48, rhubarbpieguy <at> gmail.com wrote:
>>
>> I'd like to create a macro for a user-defined date format (H:MMa/p).  As
>> examples, 7:00 AM would display as 7:00a and 3:33 PM as 3:33p. I can
>> create the format manually, but I understand the LibreOffice format
>> can't save user-defined formats.  So my thought is to create a macro
>> which creates the format each time the spreadsheet is opened. The
>> user-defined Format Code is for a saved Style.
>>
>> The macro records without incident and the date format is correct.
>> However, running the saved macro doesn't change the format.  It seems
>> this should work.  Thoughts?  The recorded macro is as follows:
>>
>
> Hello,
>
> The issue is a known one (AOO bug #66842). The office seems to support 
> some format codes that have no equivalent expression in the ODF standard.
> It has been discussed in a productive manner here:
> http://user.services.openoffice.org/en/forum/viewtopic.php?f=9&t=53724
> http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=55344
>
> I attached simple Basic macro to a demo document:
> http://user.services.openoffice.org/en/forum/download/file.php?id=14598
>
> It links number formats to cell styles so the newly generated number 
> formats applies to all the cells where the style is in use.
>
> Hope this helps,
(Continue reading)


Gmane