Ask Your Question
0

Checkbox visible/invisible

asked 2019-01-28 15:53:27 +0200

billsundial@gmail.com gravatar image

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

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"
  else
    oControl.EnableVisible = true 
    Hide_Named_CheckBox = "Visible"
  end if

end function
edit retag flag offensive close merge delete

Comments

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 +0200 )edit

I am using LO 6 on Bionic Bunny At the line: oControl=oForm.GetByName(ChkBoxName) I get"Basic Runtime error Argument not optional"

billsundial@gmail.com gravatar imagebillsundial@gmail.com ( 2019-01-28 16:45:42 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

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

JohnSUN gravatar image

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

(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

=HIDE_NAMED_CHECKBOX(A2;A1)

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

Comments

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

billsundial@gmail.com gravatar imagebillsundial@gmail.com ( 2019-01-30 20:30:58 +0200 )edit

See example in my answer

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

Question Tools

1 follower

Stats

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

Seen: 70 times

Last updated: Jan 30