I wish to create a word document containing field values for a parent recordset and child recordsets. I have created a word template that contains a table to control layout. In each cell I have created a bookmark to insert the recordset values. This works fine for all parent recordset fields.
For the child recordset values, I decided to create a nested table inside one of the template table cells using its bookmark to insert the nested table in the correct place. Each field in this nested table can then be populated with a value from the child recordset.
The issue I am having is how do a reference the cells in the child tables.
After adding two child tables to the parent table in the word document with the code below:
At the end of the routine, if I attempt to count the tables, only 1 is returned not the three I expected.
> returns 1
When I try to loop through all tables, it only loops once:
So on the face of it, there appears to be only one table, yet if I open up the word document and tab though the fields, sub tables have definitely been created, see attached image (table borders have been manually created to show they exist).
So I am confused regarding how to reference the sub tables and hence populate them both DAO.
I haven't included all the code because it is very lengthy and refers to numerous equally long sub routines
Can anyone advise what is happening and how I can reference the sub tables.
For the child recordset values, I decided to create a nested table inside one of the template table cells using its bookmark to insert the nested table in the correct place. Each field in this nested table can then be populated with a value from the child recordset.
The issue I am having is how do a reference the cells in the child tables.
After adding two child tables to the parent table in the word document with the code below:
Code:
Set rDiscussions = objWordDoc.Bookmarks.Item("Discussions").Range
objWordDoc.Tables.Add Range:=rDiscussions, NumRows:=3, NumColumns:=2
Set rTasks = objWordDoc.Bookmarks.Item("Tasks").Range
objWordDoc.Tables.Add Range:=rTasks, NumRows:=5, NumColumns:=5
At the end of the routine, if I attempt to count the tables, only 1 is returned not the three I expected.
Code:
Debug.Print objWordDoc.Tables.Count
When I try to loop through all tables, it only loops once:
Code:
For Each tbl In objWordDoc.Tables
Debug.Print tbl.Id
Debug.Print tbl.Title
Next
So on the face of it, there appears to be only one table, yet if I open up the word document and tab though the fields, sub tables have definitely been created, see attached image (table borders have been manually created to show they exist).
So I am confused regarding how to reference the sub tables and hence populate them both DAO.
I haven't included all the code because it is very lengthy and refers to numerous equally long sub routines
Can anyone advise what is happening and how I can reference the sub tables.