'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.LinqImportsGrapeCity.Documents.Word '' This sample shows how to split a DOCX into several documents.'' To see see the original document, run the SampleParagraphs sample.PublicClassSplitDocsPublicFunctionCreateDocx() AsGcWordDocument'' The document will be split before the paragraph beginning withConstp2start = "This is the second paragraph of the original document" Dim doc = NewGcWordDocument() doc.Load(Path.Combine("Resources", "WordDocs", "SampleParagraphs.docx")) Dim rng0 AsRangeBase = Nothing, rng1 AsRangeBase = NothingForEach p In doc.Body.ParagraphsIf p.GetRange().Text.StartsWith(p2start) Then rng0 = doc.Body.GetPersistentRange(doc.Body.Start, p.Previous.End) rng1 = doc.Body.GetPersistentRange(p.Start, doc.Body.End)ExitForEndIfNext If rng0 IsNothingOrElse rng1 IsNothingThenThrowNew Exception("Unexpected: could not find the split point.")EndIf Dim docs = doc.SplitDocument(rng0, rng1)If docs.Count() <> 2ThenThrowNew Exception("Unexpected: the split should have returned 2 documents.")EndIf '' Return the 2nd of the two documents (the one starting with 'p2start':Return docs.Last()EndFunctionEndClass