Click or drag to resize
FindReplaceDirection Enumeration
Specifies direction for replace operations.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
public enum FindReplaceDirection
  Member nameValueDescription
Forward0 Matched items are replaced from first to last.
Backward1 Matched items are replaced from last back to first.
Shows how to insert content of one document into another during a customized find and replace operation.
Document mainDoc = new Document(MyDir + "InsertDocument1.doc");

    FindReplaceOptions options = new FindReplaceOptions();
    options.Direction = FindReplaceDirection.Backward;
    options.ReplacingCallback = new InsertDocumentAtReplaceHandler();

    mainDoc.Range.Replace(new Regex("\\[MY_DOCUMENT\\]"), "", options);
    mainDoc.Save(ArtifactsDir + "InsertDocumentAtReplace.doc");

private class InsertDocumentAtReplaceHandler : IReplacingCallback
    ReplaceAction IReplacingCallback.Replacing(ReplacingArgs args)
        Document subDoc = new Document(MyDir + "InsertDocument2.doc");

        // Insert a document after the paragraph, containing the match text.
        Paragraph para = (Paragraph) args.MatchNode.ParentNode;
        InsertDocument(para, subDoc);

        // Remove the paragraph with the match text.

        return ReplaceAction.Skip;
See Also