Skip to content

Instantly share code, notes, and snippets.

@mniak
Created November 23, 2021 10:25
Show Gist options
  • Save mniak/62935e028204cd8b3dc4863a4b793320 to your computer and use it in GitHub Desktop.
Save mniak/62935e028204cd8b3dc4863a4b793320 to your computer and use it in GitHub Desktop.
TimeTracker macro for LibreOffice
const START_COLUMN = 0
const STOP_COLUMN = 1
const MAX_ROW = 1000
function FormattedDate as string
FormattedDate = Format(Now, "yyyy-mm-dd hh:mm:ss")
end function
sub Checkpoint
let sheet = ThisComponent.CurrentController.ActiveSheet
let row = 0
let startCell = sheet.getCellByPosition(START_COLUMN, row)
let stopCell = sheet.getCellByPosition(STOP_COLUMN, row)
do until stopCell.string = "" or row > MAX_ROW
startCell = sheet.getCellByPosition(START_COLUMN, row)
stopCell = sheet.getCellByPosition(STOP_COLUMN, row)
row = row + 1
loop
if startCell.string = "" then
startCell.string = FormattedDate
else
stopCell.string = FormattedDate
end if
end sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment