[Solved] Radio buttons on Calc spreadsheet
Posted: Tue Nov 25, 2008 7:42 pm
I have a small spreadsheet with a button and three radio buttons and one ordinary button hat I click to run a macro, PushButton.
The radio buttons all have the same name, Options, so that they are grouped together and hence mutually exclusive. They are labeled Option 1, Option 2, and Option 3 respectively.
I would like a small macro in OOBasic, so that after I have selected an option, I click on the button a message box is displayed stating which option has been chosen.
I have written some code, based on the documentation at http://wiki.services.openoffice.org/wik ... ment_Forms which gives an example in OOBasic, and on forum responses to similar requests.
However, when I click on the button I get the error message
An exception has occurred
Type.com.Sun.lang.IlleagalArgumentException
Message: arguments len differ
The code that I have developed is as follows
Global oDocument as Object
Global oDrawPage as Object
Global oForm as Object
Global oModelOpt as Object
Global oGroup as Object
Global res as Object
Sub Main
End Sub
Sub PushButton
dim msg as string
msg = "you have selectd option: "
oDocument = ThisComponent
oDrawPage = oDocument.DrawPages.getByIndex(0) ' for Sheet No 1 (every sheet has a drawpage)
oForm = oDrawPage.getForms.getByIndex(0) ' for the first form
if oForm.HasByName("Options") then
oModelOpt = oForm. GetGroupbyName("Options")
end if
msg = msg + res
msgbox msg
End sub
where PushButton is invoked by clicking on a button.
The line oModelOpt = oForm. GetGroupbyName("Options")
is the line that is highlighted as the error.
I would be grateful if anyone can suggest how I can eliminate the error message and return a result indicating which option has been selected.
Thanks for the help
The radio buttons all have the same name, Options, so that they are grouped together and hence mutually exclusive. They are labeled Option 1, Option 2, and Option 3 respectively.
I would like a small macro in OOBasic, so that after I have selected an option, I click on the button a message box is displayed stating which option has been chosen.
I have written some code, based on the documentation at http://wiki.services.openoffice.org/wik ... ment_Forms which gives an example in OOBasic, and on forum responses to similar requests.
However, when I click on the button I get the error message
An exception has occurred
Type.com.Sun.lang.IlleagalArgumentException
Message: arguments len differ
The code that I have developed is as follows
Global oDocument as Object
Global oDrawPage as Object
Global oForm as Object
Global oModelOpt as Object
Global oGroup as Object
Global res as Object
Sub Main
End Sub
Sub PushButton
dim msg as string
msg = "you have selectd option: "
oDocument = ThisComponent
oDrawPage = oDocument.DrawPages.getByIndex(0) ' for Sheet No 1 (every sheet has a drawpage)
oForm = oDrawPage.getForms.getByIndex(0) ' for the first form
if oForm.HasByName("Options") then
oModelOpt = oForm. GetGroupbyName("Options")
end if
msg = msg + res
msgbox msg
End sub
where PushButton is invoked by clicking on a button.
The line oModelOpt = oForm. GetGroupbyName("Options")
is the line that is highlighted as the error.
I would be grateful if anyone can suggest how I can eliminate the error message and return a result indicating which option has been selected.
Thanks for the help