Guddi

Guddi

  • NA
  • 3
  • 4.6k

Populate the cells in MS office word document table using C#

Jun 19 2013 5:49 AM
 Hi,

I want to populate the table found in Function.docx.

I want to fill the cell(4,4) with "someString" ,I have written the code using interop as follows.

Application application = new Application();
 Microsoft.Office.Interop.Word.Document doc = application.Documents.Open(Environment.CurrentDirectory + "\\Functions.docx", ReadOnly: false, Visible: false);
 Microsoft.Office.Interop.Word.Table table = doc.Tables[1];
table.Cell(4, 4).Range.Text = "someString";


But it shows an error in a message box saying that the document Function.docx is locked by the me. Do you want to open the file as read only.
Anybody please tell me a solution. I just have lot many files like this and want to populate them all in series. I want everything to be automated.



Answers (2)