Last post Oct 08, 2007 10:20 AM by smalhotra
Oct 08, 2007 07:46 AM|smalhotra|LINK
I have a word template which I have to populate dynamically on my website. The problem is how do I handle a table with variable number of rows. i.e. One user might need a table with 5 rows while another with 3 rows.
Either i need to know how i can add rows dynamically or remove them.
Currently I have a template with ## Name ## placeholders and i use a find and replace strategy. For the tables I have made 10 rows and named them ## Name1 ## ## Phone1##. It works fine. But I have excess rows left in the end.
I am making a web project with VB.NET code behind.
Oct 08, 2007 09:01 AM|ca8msm|LINK
How do you know how many rows the user needs? If it's from a database, you could use a Repeater to write out a record for each row, whereas if it's user input that determines the number of rows, you can create the rows dynamically and add them to the table
Dim tr As New TableRow
Website Design Darlington - http://lessthandot.com -
Oct 08, 2007 10:20 AM|smalhotra|LINK
So i read records from the database, so if the select query returns 4 rows, the table will have 4 rows.
The problem I am facing is that i am using a template, so the table is already present, how to i name the table or access it, to be able to add a row.
Also the code you wrote gives an error : Object has been deleted when i say rows.add(tr)
Dim oTable As Word.Table
oTable = oDoc.Tables.Add(oPara1.Range, 3, 4)
Dim tr As New TableRow()