Ask Your Question

Checkbox visible/invisible

asked 2019-01-28 15:53:27 +0100 gravatar image

updated 2019-01-28 17:12:00 +0100

JohnSUN gravatar image

Libre 6 on Bionic Bunny I found the following code snippet on an OO forum but cant seem to make it work on LO Can somebody "translate" it into LO Basic

Function Hide_Named_CheckBox(ChkCondition as integer, ChkBoxName as string) as string

 Dim oDoc As Object
 Dim oSheet As Object
 Dim oDrawPage As Object
 Dim oForm As Object
 Dim oControl_1 As Object

oDoc = ThisComponent
oSheet = oDoc.GetCurrentController.Activesheet
oDrawPage = oSheet.DrawPage 
oForm = oDrawPage.getForms().getByIndex(0)
oControl = oForm.getByName(ChkBoxName)

  if ChkCondition = 1 then
    oControl.EnableVisible = false
    Hide_Named_CheckBox = "Invisible"
    oControl.EnableVisible = true 
    Hide_Named_CheckBox = "Visible"
  end if

end function
edit retag flag offensive close merge delete


but cant seem to make it work on LO

What could that mean? do you say that it gives you errors? which? on which data? with which LO version ("Libre 6" is not a valid version number)?

Mike Kaganski gravatar imageMike Kaganski ( 2019-01-28 15:57:07 +0100 )edit

I am using LO 6 on Bionic Bunny At the line: oControl=oForm.GetByName(ChkBoxName) I get"Basic Runtime error Argument not optional" gravatar ( 2019-01-28 16:45:42 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-01-28 17:43:19 +0100

JohnSUN gravatar image

updated 2019-01-30 22:51:03 +0100

(Most likely you are trying to EXECUTE a function (run it without parameters), and not CALL it)

Write the name of the checkbox in A1, write in A2 zero, write the formula in A3


Make sure the form is not in design mode.

Design mode

Now change value in A2, set 1 or 2 or again zero and see result

Upd. See example C:\fakepath\VisibleChkBox.ods

edit flag offensive delete link more


I copy and pasted the function as posted but I get#Name? in A3. This on a computer that is running OO 4 and not LO gravatar ( 2019-01-30 20:30:58 +0100 )edit

See example in my answer

JohnSUN gravatar imageJohnSUN ( 2019-01-30 22:52:31 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-01-28 15:53:27 +0100

Seen: 126 times

Last updated: Jan 30 '19