Amazon Textract - Multipage document with multiple tables

I am trying to output multiple datatables using Amazon Textract activities and having some trouble.

Amazon Scope is working, connected to S3 bucket and the document I am analyzing, no issues there.

My problem is that this multipage document has multiple datatables that I need to output. I have:

For each item in PageDetail,
if item.HasTableData,
For Each table in pageDetail(0).tables,
Output Data Table (referencing pageDetail(0).Tables(0))

I would like to Write Line this output dt for each table. I then have a Clear DataTable activity after Output DataTable to reset it for each dt in the ‘for each’.

I am not sure what is going wrong - the error I am getting when running is “A column named “(my column name)” already belongs to this datatable”. I don’t know if I have the correct syntax in the Output Data Table properties or Clear Data Table.

I don’t see much documentation on working with datatables in Textract or pageDetail variables. Can anyone help?


Update - I solved the column name exception by unchecking Discover Column Headers, but now am getting the error “object reference not set to instance of an object” and am not sure what this applies to…

Use the Step Into feature of UiPath to find which activity causes this.