Yes, @karolus warned about exactly this - the macro is designed to be called by an event from a button
If you need it to be able to be called both from the button and from the Run menu, then the script code will be much longer
Sub ResetAllCheckboxesOnSheet(Optional oEvent As Variant)
Dim oDrawPage As Variant, i As Long
Dim oControl As Variant, oModel As Variant
If IsMissing(oEvent) Then
oDrawPage = ThisComponent.getCurrentController().getActiveSheet().getDrawPage()
For i = 0 To oDrawPage.getCount()-1
oControl = oDrawPage.getByIndex(i)
If oControl.supportsService("com.sun.star.drawing.ControlShape") Then
oModel = oControl.getControl()
If oModel.supportsService("com.sun.star.form.component.CheckBox") Then oModel.State = False
EndIf
Next i
Else
For Each oControl In oEvent.Source.getContext().getControls()
oModel = oControl.getModel()
If oModel.supportsService("com.sun.star.form.component.CheckBox") Then oModel.State = False
Next oControl
EndIf
End Sub
Did @Villeroy write to you? Or was he writing to someone else? It doesn’t matter, he wrote this many, many times: attempts to turn a spreadsheet into a database were made more than once and sooner or later failed - the project became unmanageable, the accumulated data was lost, the developer went crazy and became depressed… Don’t do that - use a database: it is databases that are invented, developed and intended for the accumulation, storage, and processing of data. And spreadsheets are a means for calculations, don’t get confused!
PS. By the way, my nickname has 7 letters - the first four are the normal spelling of the name John, the last three can mean Stanford University Network (or if you don’t know what that is, then just let it mean the Sun)