AddFromRange Method

Microsoft Word Visual Basic

Creates one or more subdocuments from the text in the specified range and returns a SubDocument object.

Note  The range must begin with one of the built-in heading level styles (for example, Heading 1). Subdocuments are created at each paragraph formatted with the same heading format used at the beginning of the range. Subdocument files are saved when the master document is saved and are automatically named using text from the first line in the file.

expression.AddFromRange(Range)

expression    Required. An expression that returns a Subdocuments object.

Range    Required Range object. The Range object used to create one or more subdocuments.

Example

This example creates one or more subdocuments from the selection.

ActiveDocument.ActiveWindow.View.Type = wdMasterView
ActiveDocument.SubDocuments.AddFromRange Range:=Selection.Range