'What is the code to create a new sheet in LibreOffice? Additionally, how do I rename that sheet?

I am well-versed in Excel vba that I use for work, but I chose to use LibreOffice for this personal project because I don't have a personal MS Office license. Below is the code I currently have written.

Sub Setup
    Dim oSheets
    Dim oBoardSheet
    Dim oTurnSheet
    Dim sReturn As String
    Dim iRoll As Integer
    Dim sIBinfo As String
    Dim sIBMsg As String
    Dim sIBTitle As String
    Dim sNewSheet As String
    
    oSheets = ThisComponent.Sheets
    sNewSheet = Format(Now,"mm-dd-yy")
    oSheets.insertNewByName(sNewSheet,2)
    
    oBoardSheet = oSheets.getByName("3-4PlayerBoard")
    oTurnSheet = oSheets.getByName(sNewSheet)


Solution 1:[1]

LO has 2 ways of creating macro: recording macro that records some user actions via dispatcher (not recommended) and API real code that should be typed or created using MRI extension. Short overview of Calc Basic code is at https://wiki.documentfoundation.org/Macros/Basic/Calc and https://documentation.libreoffice.org/en/english-documentation/macro/ and full Pitonyak guide at https://www.pitonyak.org/oo.php.

Seems like parenthesis missing.

oSheets = ThisComponent.getSheets()  
oSheets.insertNewByName("sNewSheet", 2)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1