Here is a simple function that gives the same error. It gets the name of the current sheet.
Code: Select all
Function SheetName( SheetNum As Integer )
SheetName = ThisComponent.getSheets.getByIndex(SheetNum-1).getName()
End Function
Code: Select all
=SheetName(sheet())
Even if this is not the best way to get the name of the current sheet, I still need to figure out how to access ThisComponent for my recursive function. Here's the code for my recursive function in case that helps. It's called using =FindName("name", sheet()) (which starts the search on the next sheet, since sheet() starts counting at 1 and getByIndex() starts counting at 0).
Code: Select all
Function FindName( Name As String, CurSheet As Integer )
If Name = "" Then
FindName = ""
Else
FindName = FindNameInSheet(Name, CurSheet)
End If
End Function
Function FindNameInSheet( Name As String, SheetNum As Integer )
LastSheet = ThisComponent.getSheets().Count
If SheetNum = LastSheet Then
FindNameInSheet = ""
Else
Sheet = ThisComponent.getSheets().getByIndex(SheetNum)
NamesCol = Sheet.getCellrangeByName("A1:A100")
SearchDesc = NamesCol.createSearchDescriptor()
SearchDesc.SearchString = Name
SearchResult = NamesCol.findAll(SearchDesc)
If IsNull(SearchResult) Then
NextSheet = SheetNum + 1
FindNameInSheet = FindNameInSheet(Name, NextSheet)
Else
FindNameInSheet = Sheet.getName
End If
End If
End Function