How to make a checkbox change according to data in another cell?

From Apache OpenOffice Wiki
Jump to: navigation, search


How to make a checkbox change according to data in another cell?


In Calc enter this function
'=IF(A1=1;"True";"False")'

Now, you need to add this macro. If you don't know how, please see the user guide.

 Sub SetMyCheckBox
 Dim oForm
 Dim oControl
 Dim oSheet
 Dim oCell

	oForm = ThisComponent.Sheets(0).DrawPage.Forms.getByIndex(0)
	oControl = oForm.getByName("MyCheckbox")
	oSheet = ThisComponent.Sheets(0)
	oCell = oSheet.getCellRangeByName("A1")

	If oCell.Value = "1" then
		oControl.Value = "True" (?)
	Else
		oControl.Value = "False"
	End If
 End Sub


Personal tools