Click here to Skip to main content
15,077,428 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I have to insert text from the one word document (having header and footer) to the another word document(also having header and footer).

I just want to transfer text from one document to another document without changing header and footer.

What I have tried:

I have tried following code.

var application = new MSWord.Application();
var originalDocument = application.Documents.Open(@"C:\Word\Source.doc");

var originalText = originalDocument.ActiveWindow.Selection;

Microsoft.Office.Interop.Word._Application oWord;
object oMissing = Type.Missing;
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = false;

using this code Text is inserted from source document to destination doc. But it disturbs footer of destination document.
Dmitriy Gakh 2-Jun-16 3:35am
To insert one document into another without changing header/footer you need inserting section break in way you new text will be in new section.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900