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.
Loading
Sunny SharmaPosted Jun 19, 2013, 6:30 AM
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!
GuddiPosted Jun 20, 2013, 5:32 AM