Accessing Controls on a Spreadsheet in Basic

If I want to access a cell in a calc document using Basic, I would type something like:

sheet = ThisComponent.Sheets.getByName("mySheet").sheet.getCellByPosition(X,Y)

However, I would like to have a ‘file selection’ component on a spreadsheet. While I found a way to access these files using oEvent from a button press, is there a single line that I can type that will allow me to access the values of such a control (or a textBox) located directly on a form?

Hello,

To access a control on a sheet, first get the sheet:

oSheet=ThisComponent.CurrentController.ActiveSheet

or as you somewhat have it:

oSheet = ThisComponent.Sheets.getByName("mySheet")

Then using oSheet, get the form and the control on the form:

oControl = oSheet.getDrawPage().getForms().getByName("FORM_NAME").getByName("FIELD_NAME")

But how do I know what “FORM_NAME” is?

@someone_somewhere,

You can get all form and control names from the Form Navigator. In Calc this is an icon on the Form Design toolbar. Also see → Form Navigator