Search code examples
libreofficelibreoffice-calc

Is it possible to recalculate all cells (i.e. Ctrl+Shift+F9 function) automatically on a timer?


I have written functions that access off-sheet data that is prone to changing regularly. Pressing Ctrl+Shift+F9 refreshes these cells, while F9 alone does not. Is there a way to automate refreshing this data - say, once a minute?


Solution

  • Running libreoffice 4.4.3.2 Ok you can use a link to a value in another sheet if you like. To create a name range insert->names->define

    Sub recalc_timer
     document   = ThisComponent.CurrentController.Frame
      switch_on = ThisComponent.NamedRanges("switched_on").ReferredCells.getCellByPosition(0,0)
     dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    
     rem value must be more than 0 to hold while condition
    
     while switch_on.getValue()>0
    
     dispatcher.executeDispatch(document, ".uno:CalculateHard", "", 0,   Array())
     rem wait time in milliseconds
     wait 3000
     wend
    End Sub
    

    *proviso

    Important: Some functions may not be updated. Please test https://help.libreoffice.org/Calc/Recalculate