This describes how to write some code and setup your worksheet to perform a certain action when a button is pressed.
View→Toolbars→Form controls
Go into design mode (This disables any button functions) Select from the form controls Push Button
Draw this button in a cell.
Change the label to something meaningful to the user:
All buttons will be useless to a user of the spreadsheet if the design mode is active. To change from design mode to active mode two more steps are required:
Paste code below into: Tools→Macros→Organize Macros→LibreOffice.org Basic…
REM Sheet containing the parts count report view Public Const SHEET_NAME As String = "NAME_OF_THIS_SHEET" Sub telop Dim oDoc As Object Dim oSheet As Object Dim oCell_1 As Object Dim oCell_2 As Object Dim cell As Object oDoc = ThisComponent oSheet = oDoc.getSheets().getByName(SHEET_NAME) oCell_1 = ThisComponent.Sheets(0).getCellRangeByName("A5") oCell_1.Value = 100 oCell_2 = ThisComponent.Sheets(0).getCellRangeByName("A6") oCell_2.Value = 200 Cell = thisComponent.Sheets(0).getCellByPosition(0, 7) Cell.Formula = "=SUM(A5:A6)" End Sub
Or an example to create a button which, when clicked, jumps to a designated sheet:
Sub gotoSheet(oEvent) Dim oCaller As Object Dim sName As String Dim oSheet As Object oCaller=oEvent.Source.Model sName = oCaller.Name oSheet = ThisComponent.getSheets().getByName(sName) ThisComponent.CurrentController.setActiveSheet(oSheet) End Sub