How do i programatically copy the contents of one word document and paste it to another word document using C#?
I basically want to copy a personal profile (which is the contents of one word doc) and then insert it into a report.
Any help would be greatly appreciated
Thanks
You can do this:
object docStart = worddocpromo.Content.End - 1;
object docEnd = worddocpromo.Content.End;
object start = SubDoc.Content.Start;
object end = SubDoc.Content.End;
SubDoc.Range(ref start, ref end).Copy();
Microsoft.Office.Interop.Word.Range rng = worddocpromo.Range(ref docStart, ref docEnd);
rng.Paste();
You can do this:
Word.Application word = new Word.Application();
word.Visible = true;
Word.Document d1 = word.Documents.Add();
Word.Document d2 = word.Documents.Open(@"E:\00-Word\Test.docx");
Word.Range oRange = d2.Content;
oRange.Copy();
d1.Content.PasteSpecial(DataType:Word.WdPasteOptions.wdKeepSourceFormatting);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With