none
How do I copy a Word document range to another document without using the clipboard ? RRS feed

  • Question

  • I'm using c# and Ms-Word.

    I want to copy paste a Word range for one document to the other.

    Range.Copy and Range.Paste use the Clipboard.
    This is not acceptable if the User makes a manula copy/paste while the programe is running  in the background.

    How do I proceed to copy/paste ranges without using the clipboard.

    I tired "myDestRange.FormattedText=mySourceRange.FormattedText". But this triggers an error "wrong argument" like.

    any idea ?

    Wednesday, March 4, 2015 12:51 PM

Answers

  • Thank you Viorel,

    I need to have a Word 2003 compatible software.... XML, I'm not sure.

    Besides, I tried and tried again... and think I found the solution.

    "myDestRange.FormattedText=mySourceRange.FormattedText" WORKS

    BUT ONLY if the destination document was created
    with "Word.Document myDocument = myWordApp.Documents.Add();"

     AND NOT with "Word.Document myDocument = new Word.Document();

    Kind regards


    • Marked as answer by Agathe0726 Wednesday, March 4, 2015 2:23 PM
    • Edited by Agathe0726 Wednesday, March 4, 2015 2:32 PM
    Wednesday, March 4, 2015 2:23 PM

All replies

  • Have you tried this: myDestRange.InsertXML(mySourceRange.XML)?

    Wednesday, March 4, 2015 1:46 PM
  • Thank you Viorel,

    I need to have a Word 2003 compatible software.... XML, I'm not sure.

    Besides, I tried and tried again... and think I found the solution.

    "myDestRange.FormattedText=mySourceRange.FormattedText" WORKS

    BUT ONLY if the destination document was created
    with "Word.Document myDocument = myWordApp.Documents.Add();"

     AND NOT with "Word.Document myDocument = new Word.Document();

    Kind regards


    • Marked as answer by Agathe0726 Wednesday, March 4, 2015 2:23 PM
    • Edited by Agathe0726 Wednesday, March 4, 2015 2:32 PM
    Wednesday, March 4, 2015 2:23 PM