Hi,
I am trying to merge multiple documents to one document, using the below code. But the second time when i was trying to open the document - oTarget = oWord.Open(sFinalDocFileName);, I am getting the error message as "file already in use by another user".
How can I release the file after every save ?
// copy process
Document oSource = new Document(sFilename);
Document oTarget = null;
if (File.Exists(sFinalDocFileName))
{
oTarget = oWord.Open(sFinalDocFileName);
}
else
{
oTarget = new Document();
oTarget.Sections.Clear();
}
foreach(Section oSection in oSource.Sections)
{
Section oNewSection = (oTarget.ImportNode(oSection, true) as Section);
oTarget.Sections.Add(oNewSection);
}
oTarget.Save(sFinalDocFileName);