Method InsertFragment
InsertFragment(WordDocument, DocumentPosition, DocumentFragment)
Inserts a fragment at a position, as Word pastes with the source formatting kept.
public static DocumentEdit InsertFragment(this WordDocument document, DocumentPosition at, DocumentFragment fragment)
Parameters
documentWordDocumentThe document that receives the content.
atDocumentPositionWhere it goes.
fragmentDocumentFragmentThe content. It is not modified and may be inserted again.
Returns
- DocumentEdit
The edit; After is just past the inserted content.
Exceptions
- ArgumentNullException
documentorfragmentis null.- ArgumentException
The position is not in
documentor falls inside a surrogate pair; or the fragment is the document itself.- InvalidOperationException
The position is in a shape's text box, inside content a reader synthesized or an inline content control that cannot hold a paragraph break; or the fragment has note references and the position is in a note.
- InvalidDocumentException
The fragment's document can no longer read its media (it was disposed).