OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Is this a bug, the "macro and fields bug"?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  

Do you think this is a bug?
yes
100%
 100%  [ 1 ]
no
0%
 0%  [ 0 ]
Total Votes : 1

Author Message
SteveH_66
General User
General User


Joined: 01 Oct 2006
Posts: 16

PostPosted: Thu Oct 05, 2006 5:29 pm    Post subject: Is this a bug, the "macro and fields bug"? Reply with quote

OK, I think that this date and time in a macro thing is a bug. Here is what I do to make the macro:

I click on tools > macro > record macro
I click on the toolbar button to center my text
I click on insert > fields > other, and then I select the type of date that I want, leaving it set as fixed
I close the fields box, which is what was opened up to select the type of date I want
I put in 5 tabs
I click on insert > fields > other, and then I select the type of time that I want, leaving it set as fixed
I close the fields box
I hit enter twice to give me a blank line and put the cursor on a second line
I click on the left justify button on the toolbar, to left justify my text
I click on stop recording macro and name my macro

OK. In past versions of Open Office, this worked great when done exactly as I described above. (The following examples just aren't formatting the way I use them). Any time I opened up a new document, I could run this macro and get the date and time in the format I wanted, for example:
Fri, October 06, 2006 6:55 PM

When I first record the macro in ver. 2.0.3, it works great in the document I recorded it in. Can use it repeatedly and it works. Can save the document and open it later, and it works fine. But in a new document it puts in the raw data like:

38995.79 38995.79

It also does this in a document that I create the macro in and use the macro in (and it works great in the document as long as it is in Open Office Writer format) but if I use 'save as' and save the document in another format such as .rtf then it doesn't work - again it puts the data in raw format.

Now I HAVE found a workaround:

You use the macro in a new document. It puts the data in as raw data, but spaced and everything the way you wanted it. You select one of the fields and right click, and on the pop-up menu that comes up you select fields, and go back and reselect the date in the format you want and click on OK. At this point, it doesn't change it back, it stays as the raw data format. Then, you click on view > field names. Now, the fields go to this format :

Date (fixed) Time (fixed)

OK. Now, you go back and click on view > field names (which deselects viewing as field names) again, and after you do this it changes back, but instead of the raw data format you get the date in the format you want and the time in the format you want, spaced and laid out the way you wanted it to.

Of course this is a lot of steps to go through in a document where you might only want to use the date and time once. Better to just Insert the data and insert the time, laying it out in whatever arrangement you want to have it in manually. Lot less work and a lot less steps. I tried doing the macro in a blank new document, erase everything and then save that document as the default document. But this doesn't work as a work-around, you get the raw data and have to go through the work-around I described above. The following is the macro text you get when you click on edit in the macro window :

Begin Macro Code ---------------------------------------------------------------------

REM ***** BASIC *****

Sub Main

End Sub







sub DateTime
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 = "CenterPara"
args1(0).Value = true

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

rem ----------------------------------------------------------------------
dim args2(5) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Type"
args2(0).Value = 0
args2(1).Name = "SubType"
args2(1).Value = 0
args2(2).Name = "Name"
args2(2).Value = ""
args2(3).Name = "Content"
args2(3).Value = "0"
args2(4).Name = "Format"
args2(4).Value = 5078
args2(5).Name = "Separator"
args2(5).Value = " "

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

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Text"
args3(0).Value = CHR$(9)+CHR$(9)+CHR$(9)+CHR$(9)+CHR$(9)

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args3())

rem ----------------------------------------------------------------------
dim args4(5) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Type"
args4(0).Value = 1
args4(1).Name = "SubType"
args4(1).Value = 0
args4(2).Name = "Name"
args4(2).Value = ""
args4(3).Name = "Content"
args4(3).Value = "0"
args4(4).Name = "Format"
args4(4).Value = 5042
args4(5).Name = "Separator"
args4(5).Value = " "

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())

rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "LeftPara"
args7(0).Value = true

dispatcher.executeDispatch(document, ".uno:LeftPara", "", 0, args7())


end sub

End Macro Code ----------------------------------------------------------------------------

I researched through the forums and couldn't find a way to fix this. I found a lot of posts where people said download my macros and use them. Or showed their macro code in the post itself, which would be a great help, unfortunately it was for other problems that don't exactly meet mine. Does anyone know settings in the writer or main Open Office options which might be set wrong and causing this, or any settings that are wrong anywhere in the program that would be causing this? Also, does anyone see how the 2 blocks of code that control the date and time can be modified in the macro as it stands now so that I can get the fixed date and time in the format I want? I like the date format Fri, October 06, 2006 and the time format 01:45 PM. Many thanks for any help anyone can give me on this problem, Steve

P.S. Do you think this is a bug in this version of OOO?
Back to top
View user's profile Send private message
noranthon
Super User
Super User


Joined: 07 Jul 2005
Posts: 3318

PostPosted: Thu Oct 05, 2006 6:47 pm    Post subject: Reply with quote

It seems to me that the date setting mechanism in Writer needs a lot of attention but whether it's worth going through the hoops of filing issues is up to the user.

I also dislike the default date format and I think the simplest option would be to enable users to change the default date format in their applications.

Further, I have found that neither fixed date nor the other option works in a template. Fixed date can stay fixed at some random point irrespective of the date you use the template to create a new document. The other option results in today's date being displayed each time you open the document.

I use Writer so little that it's simpler for me just to type in the date. If I was in the unfortunate position of having to use it a lot, I would consider the date/time macro on < oomacros >.
_________________
search forum by month
Back to top
View user's profile Send private message
DetlevSchm
General User
General User


Joined: 07 Jan 2006
Posts: 19

PostPosted: Sat Nov 18, 2006 11:57 pm    Post subject: Reply with quote

noranthon wrote:
I also dislike the default date format and I think the simplest option would be to enable users to change the default date format in their applications.

I strongly agree. On all platforms the operating system allows users to customize the date/time depiction and most software simply use this user's preference. OOo does not only make no use of this feature, but cumbersomely implements an inferior alternative. Sorry for having said this, because I am a big OOo fan, despite all limitations.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group