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

CALC: Help needed for a macro to capture time in calc.

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


Joined: 01 Jul 2012
Posts: 2

PostPosted: Mon Jul 02, 2012 4:19 am    Post subject: CALC: Help needed for a macro to capture time in calc. Reply with quote

Hello All,

I am new to openoffice since i migrated a few days back. I am at my wits end since calc is very different from excel. Here is brief points on what iam trying to do in the macro:

1) i have two buttons "Start" and "End".
2) when start is clicked it should print time and when end is clicked it should capture the time.
3)when again start is clicked it should capture time in next cell i.e. in the below cell without deleting or updating the time in the before cell.
4) same is the case with End button.

Your help would be appreciated very much.

@Moderator, if this is the wrong thread to post kindly point me to the original post.



Moderation probe1: moved to MACROS AND API section, where all macro related questions belong to; edited subject
_________________
Gundabk.
Back to top
View user's profile Send private message
davidh182
OOo Advocate
OOo Advocate


Joined: 01 Apr 2004
Posts: 413

PostPosted: Sun Jul 15, 2012 4:22 am    Post subject: Reply with quote

There are several stages: including java, permitting macros to run, setting a button to launch a macro, searching for an empty cell using while()
The code to set a time in a cell is:

Code:


sheet=StarDesktop.CurrentComponent.CurrentController.ActiveSheet

sheet.getCellByPosition(0,0).setFormula("=NOW()")
sheet.getCellByPosition(0,0).NumberFormat=50
sheet.getCellByPosition(0,0).String=sheet.getCellByPosition(0,0).String


ie use the spreadsheet function NOW
Format as a date/time
copy the value so that it's fixed

To use a different format, format cell A1 as required and use




Code:

msgbox sheet.getCellByPosition(0,0).NumberFormat

to discover the format code number (may not be portable).
Back to top
View user's profile Send private message Send e-mail
gundabk
Newbie
Newbie


Joined: 01 Jul 2012
Posts: 2

PostPosted: Thu Jul 19, 2012 5:42 am    Post subject: Help needed for a macro to capture time in calc. Reply with quote

Thanks davidh182,

I tried to execute but got error saying Error ....... it is not optional.
Crying or Very sad
_________________
Gundabk.
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