How to vary rows in DDE-linked table in Writer?

How can I vary the number of rows in a DDE-linked Writer table, to correspond with the number in the Calc data source?

Backstory: I am using GnuCash with MySQL storage for some accounts I am responsible for. I need to produce individual statements - I use MySQL procedures for this, called by a OOo Basic macro in Calc to populate a cell range with the statement data. I have a Writer document containing the statement blurb, with a DDE-linked table to pick up the numeric data for each account from Calc.

Everything works fine except that the number of rows can vary between individual accounts, meaning I either have blank rows at the bottom or miss some rows out, depending on how long the table is when I initially create it. The DDE link references the target range in Calc, so gets all the data but can’t display it if it runs out of rows. I can’t alter the table in Writer as it is linked - is there some way to do this in Basic, or an alternative programmatic way to insert the numeric data?

Thanks,
Andrew