Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a row to an MS Word table using Office.Interop

I have a word template with a table that I am populating from a list of strings that I split using tab characters.

I do not know how many lines of text I will have as it will vary.

So I am adding a row programmatically before iterating through my loop like this:

oWordDoc.Tables[2].Rows.Add(oWordDoc.Tables[2].Rows[1]);

Unfortunately it is adding the row before rather than after the current row.

How can I change my code to always have an empty row added after the current row?

like image 579
Our Man in Bananas Avatar asked Dec 18 '13 16:12

Our Man in Bananas


1 Answers

I found it, it should be:

Object oMissing = System.Reflection.Missing.Value;
oWordDoc.Tables[2].Rows.Add(ref oMissing); 
like image 56
Our Man in Bananas Avatar answered Oct 04 '22 21:10

Our Man in Bananas