Want to enter a macro in one cell of a spreadsheet and have it calculate something. Need it to automatically run when the spreadsheet is opened.
For example, the following returns the number of sheets:
Function Number_of_Sheets()
Dim oSheets
Dim oSheet
oSheets = ThisComponent.getSheets()
oSheet = oSheets.getCount()
Number_of_Sheets = oSheet
End Function
In the spreadsheet, I enter:
=number_of_sheets()
in a particular cell and right away the cell contains the number of sheets open in that particular spreadsheet. The macro is in the standard library under “My Macros & Dialogs”.
But if I close the spreadsheet and then re-open it, I get a message box saying " Due to an unexpected error, LibreOffice has crashed. All the files…" and I have to go through the procedure to recover the file.
What must I do to fix this?