| View previous topic :: View next topic |
| Author |
Message |
gundabk Newbie

Joined: 01 Jul 2012 Posts: 2
|
Posted: Mon Jul 02, 2012 4:19 am Post subject: CALC: Help needed for a macro to capture time in calc. |
|
|
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 |
|
 |
davidh182 OOo Advocate

Joined: 01 Apr 2004 Posts: 413
|
Posted: Sun Jul 15, 2012 4:22 am Post subject: |
|
|
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 |
|
 |
gundabk Newbie

Joined: 01 Jul 2012 Posts: 2
|
Posted: Thu Jul 19, 2012 5:42 am Post subject: Help needed for a macro to capture time in calc. |
|
|
Thanks davidh182,
I tried to execute but got error saying Error ....... it is not optional.
 _________________ Gundabk. |
|
| Back to top |
|
 |
|