Merging more than one document to one document



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);




oTarget = new Document();



foreach(Section oSection in oSource.Sections)


Section oNewSection = (oTarget.ImportNode(oSection, true) as Section);





The message like "file already in use by another user" is usually given when the document you are trying to open by Aspose.Word is already opened in MS Word.

Also, normally you should use Word.Open method nly for COM interop,

otherwise just use

oTarget = new Document(sFinalDocFilename);