On Wednesday 02 February 2005 23:08, Andrew Douglas Pitonyak wrote:
> 
> Michel Franckart wrote:
> 
> >On Sunday 30 January 2005 14:09, G. Roderick Singleton wrote:
> >  
> >
> >>On Sun, 2005-01-30 at 13:27 +0100, Michel Franckart wrote:
> >>    
> >>
> >>>This bug was already present in 1.1.3.
> >>>
> >>>I generate a macro that inserts the date with format '31 dÃcembre 1999' 
> >>>(Insert > Fields > Other ...).
> >>>When I launch that macro in another document, the date is replaced by a 
> >>>figure e.g. '38382.56' !
> >>>
> >>>Not very important.
> >>>
> >>>Many thanks for your attention and, of course, for that beautiful OOo.
> >>>
> >>>A layman.
> >>>
> >>>      
> >>>
> >>THe default format for a Calc cell is number not date. Please fix your
> >>macro so that it sets the cell format properly. By not doing so you get
> >>the result you have.
> >>
> >>    
> >>
> >Sorry, the question was not clear.
> >
> >- I am working in text documents (.sxw) ;
> >- The macro is a recorded one ;
> >- It is meant to automatically insert the date of the day (fixed) into a 
> >document (letter).
> >
> >Additionally :
> >- The 'bug' occurs when I launch the macro in a  n_e_w  document, not when I 
> >relaunch it inside the document where it was created.
> >Also strangely, the figure (e.g. '38382.56') transforms into the right date 
> >format if, somewhere else in my document, I perform the same date insert 
> >manually !
> >
> >Kind regards.
> >
> >  
> >
> You should post the code :-)
> 
> The problem is PROBABLY is as follows:
> The insertion macro probably inserts a field. The field probably 
> contains a number, which represents the date. The number is formatted to 
> be a date using a numeric style. The style that is assigned to format 
> the number is simply an index into an array of numeric styles supported 
> by your document. In a new document, the style that you want may not yet 
> exist. This is just a guess, of course....
I think it's the right guess.
> 
> My free macro document contains a section titled
> 
> 
>       Insert a formatted date field into a Writer document
> 
> 
> There is a corresponding macro for inserting into a Cell in a Calc 
> document. The trick is that this macro uses a routine called:
> 
> FindCreateNumberFormatStyle("DD. MMMM YYYY", oDoc)
> 
> This finds the correct formatting style to use. The document contains 
> this routine as well.
> 
> -- 
> Andrew Pitonyak

Many thanks.
I have solved my problem on the basis of your 
'Insert a formatted date field into a Writer document'

Nevertheless, I wonder if the recorded macro isn't buggy.
Why does it not (always) apply the recorded format value ?
Or why does it not create the style in the new document like 
"Insert->Fields->Other->Date(fixed)->Format" does ?
That would make things a lot easier !

Here is the recorded macro :
--------------------------------------------------------------------------
sub essai03
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(5) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Type"
args1(0).Value = 0
args1(1).Name = "SubType"
args1(1).Value = 0
args1(2).Name = "Name"
args1(2).Value = ""
args1(3).Name = "Content"
args1(3).Value = "0"
args1(4).Name = "Format"
args1(4).Value = 5076
args1(5).Name = "Separator"
args1(5).Value = " "

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


end sub
-----------------------------------------------------------------------------

Kind regards

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to