While adding a new row into word document table I faced a next error:-
System.Runtime.InteropServices.COMException: 'The requested member of the collection does not exist.'
The complete code that I used:-
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
object miss = System.Reflection.Missing.Value;
object path = string.Format(@"Doc_Path_here");
object readOnly = false;
Microsoft.Office.Interop.Word.Document doc = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
doc.Tables[0].Rows.Add();
I tried the solutions that existing here and here without any positive result.
any help is appreciated.
Update:-
The word document has one table, this is confirmed,
and also the result nCount
variable of next code is 1
int nCount = doc.Tables.Count;