How do I activate a sheet in OO Basic

What’s the secret to activating a particular sheet, please?

Hello Orpheus2000,

Going strictly on the question:

oSheet = ThisComponent.Sheets.getByName("Sheet_Name_To_Activate")
ThisComponent.CurrentController.setActiveSheet(oSheet)

will activate a particular existing sheet.

If you just wish to access a sheet:

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

or

oSheet=ThisComponent.CurrentController.ActiveSheet

Once you have the sheet you can get at specific info:

oCell = oSheet.GetCellRangeByName("A1")
oCell.setString("Hello")

For much more info on macros in Calc, here is the PDF for Open Office Macros Explained by Andrew Pitonyak → OOME

It is the best single source for LO/AOO macros.

Thanks for that, and I now have Andrew Pitonyak’s PDF, which looks to be exactly what I needed.

I add as a reminder the following: Dim oSheet As Object. This is in case you also put “Worksheet”, instead of “Object”. Thank you.