none
Insert newline while copying content from multiple documents RRS feed

  • Question

  • I am copying content from two word documents to my existing word document.I am using the following code:

    Word.

    Range

    rng;

     

    rng = wordDoc.Range(

    Type.Missing, Type

    .Missing);//wordDoc is Word.Documnent

    rng.Copy();

     

    DocumentContext.WordApplication.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(Word.WdRecoveryType.wdPasteDefault);

     

    For each document,this code is executed.Now,I need to paste the contents of second document in the next line.How to achieve this?

     
    Friday, December 23, 2011 4:48 AM

Answers

  • In essence:

    With DocumentContext.WordApplication.ActiveDocument.ActiveWindow.Selection
      .InsertParagraphAfter
      .Collapse wdCollapseEnd
      .PasteAndFormat (Word.WdRecoveryType.wdPasteDefault)
    End With


    Cheers
    Paul Edstein
    [MS MVP - Word]
    • Marked as answer by ams16 Friday, December 23, 2011 9:27 AM
    Friday, December 23, 2011 7:08 AM