C# .NET - Blank page gets inserted during creation of word document using Word.InterOp in C#

Asked By KC KC on 01-Apr-13 04:38 PM
Hi,
I am trying to create a new wordDoc(2010) by stitching multiple docs together. Though I am successfully able to build the final Doc there seem to be some blank pages getting inserted into the document which I am unable to get rid of. I am using the Word.Interop dll in c#. Following is a snippet of the code that I am using.


var WordApp = new Application();
Document adoc = WordApp.Documents.Add();
foreach(var fileName in ListOfFiles)
{
Range rng = adoc.Range(ref start, ref missing);
rng.InsertFile(fileName, ref missing, ref missing, ref missing, ref missing);
       start = WordApp.ActiveDocument.Content.End - 1;
}
adoc.SaveAs(targetFileName);


Thanks.
KC