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.
Populate the cells in MS office word document table using C#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sunny SharmaRank #223 · 11.1K reputationPosted Jun 19, 2013, 2:30 AM EDT
your code is working all fine, the missing point is you're not saving the document after edit.
Add these codes after setting the value in Cell(4,4):
doc.Save();
doc=null; //(So that it will free your document)
Mark as answer if it helps.
Happy Coding :)
Cheers!
Guddi3 reputationPosted Jun 20, 2013, 1:32 AM EDT