Basic Macro function

Hi Folks,

I need to create a new spreadsheet in the current workbook. My code has successfully reviewed the existing sheets to verify that I will not create a tab name collision, so I have some correctly working code.

This is my problem instruction:
gncSheet = ThisComponent.Sheets.insertNewByName("gnc" & s, ThisComponent.Sheets.Count())

… produces an error: Object not accessible. Invalid use of an Object

I have confirmed that ThisComponent.Sheets.Count() returns the correct tab count, so I don’t think ThisComponent or Sheets is my problem. That leaves insertNewByName, but, inspite of the complaint, t does, in fact, create a new spreadsheet.

If it is doing the job, why is it complaining? Can anybody see what the problem is?

Thanks for the help,

Chris.

And the mistake happens on that line?
Because it works right for me.

	s = "_1"
	ThisComponent.Sheets.insertNewByName("gnc" & s, ThisComponent.Sheets.Count())

insertNewByName Do not return a sheet.

https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sheet_1_1XSpreadsheets.html#ab235b8c33bafa71d643f127b4758655e

Hi elmau,

Well, there it is. You’re advice is worth twice what I’m paying you. Give yourself a raise.

Man I wish I understood how the API documentation is organized …

Thanks for the help.

Chris.