Create new ODS from BASIC macro

Is there a way to create a new Document from a BASIC macro and manipulate that document similar to using ThisComponent? Specifically, I want to create a new ODS file, do stuff to it, then save it. The site seems to be down, so my powers are weak…but I’m not getting anywhere with the APIs.

The following function helps loading a template, so you don’t need to start the new document from scratch:

Sub Test_OpenTemplate()
doc = getOpenTemplate(sRegion:="My Templates", sType:="scalc", sTemplate:="SheetReport")
End Sub

function getOpenTemplate(sRegion$, sType$, sTemplate$)
REM sRegion "My Templates" or any other category name
REM sType: "swriter", "scalc", "simpress", sdraw"
dim p(0 to 2) as new
p(0).Name = "AsTemplate"
p(0).Value = True
p(1).Name = "TemplateName"
p(1).Value = sTemplate
p(2).Name = "TemplateRegionName"
p(2).Value = sRegion
getOpenTemplate=StarDesktop.loadComponentFromURL("private:factory/"& sType, 0, "_default", p)
End Function


new_doc = StarDesktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, Array())