Import Calc Data to Impress Slides

I have a large project 4x per year. We can export the data we need to present to CSV, so opening that data in Calc and cleaning it up is no problem at all.

So now we have ~700-800 rows and only 2 columns to deal with.

What I want is to import that data into Impress, where each row will generate it’s own slide, following a predetermined layout or template.

I’ve tried convincing and chatgpt to write some macros for me with no luck.

BASIC runtime error.
An exception occurred 
Message: at /usr/src/debug/libreoffice-fresh/libreoffice-

IDK, it’s all foreign black magic to me…

Here’s the macro it generated, for context of course, because I’m not sure how useful it is in regards to the task at hand…

Sub ImportDataFromCalcToImpress
    Dim oImpressDoc As Object
    Dim oCalcDoc As Object
    Dim oSheet As Object
    Dim oRange As Object
    Dim i As Integer
    Dim slideIndex As Integer
    ' Open Impress document
    oImpressDoc = StarDesktop.loadComponentFromURL("private:factory/simpress", "_blank", 0, Array())
    ' Open Calc document using direct method
    oCalcDoc = StarDesktop.loadComponentFromURL("file:///home/bbbbbb/mydoc.ods", "_blank", 0, Array())
    ' Check if Calc document is loaded successfully
    If Not IsNull(oCalcDoc) Then
        ' Attempt to get the Calc sheet with data
        On Error Resume Next
        oSheet = oCalcDoc.Sheets.getByName("Sheet1") 'Change "Sheet1" to your Calc sheet name
        On Error GoTo 0
        If Not IsNull(oSheet) Then
            ' Get the cell range with data
            oRange = oSheet.getCellRangeByName("A2:B100") 'Change "A2:B100" to your desired range
            ' Loop through each row of data
            For i = 0 To oRange.Rows.Count - 1
                ' Create a new slide for each row of data
                slideIndex = oImpressDoc.createInstance("").createInstance("")
                ' Import Lot # and Lot Title from Calc to Impress text boxes
                oImpressDoc.getDrawPages().insertByIndex(oImpressDoc.getDrawPages().Count, oImpressDoc.createInstance(""))
                oImpressDoc.getDrawPages().getByIndex(oImpressDoc.getDrawPages().Count - 1).setName("Slide " & slideIndex + 1)
                oImpressDoc.getDrawPages().getByIndex(oImpressDoc.getDrawPages().Count - 1).add(oImpressDoc.createInstance(""))
                oImpressDoc.getDrawPages().getByIndex(oImpressDoc.getDrawPages().Count - 1).getByIndex(0).setPosition(CreateUnoStruct("", 500, 500))
                oImpressDoc.getDrawPages().getByIndex(oImpressDoc.getDrawPages().Count - 1).getByIndex(0).setSize(CreateUnoStruct("", 2000, 500))
                oImpressDoc.getDrawPages().getByIndex(oImpressDoc.getDrawPages().Count - 1).getByIndex(0).setText(oRange.getCellByPosition(0, i).String & vbCrLf & oRange.getCellByPosition(1, i).String)
            Next i
            MsgBox("Sheet 'Sheet1' not found in Calc document.")
        End If
        ' Close Calc document
        MsgBox("Calc document not loaded successfully.")
    End If
End Sub

TY <3

Attach an ODS file with a few example lines, and the Impress template.

It’s just a standard pre-made template.

The data in the spreadsheet is just two columns, around 800 rows long… Title, Description. Nothing too profound.

Trying to find a workaround. I save the data in the spreadsheet as a database, then use LO Labels and Avery Full-Sheet to get the data to populate one row for each page. Export as PDF the import the PDF into Impress…

It’s good enough, but being able to just query the database from Impress would be more ideal.