Subdocuments.AddFromRange method (Word)
Creates one or more subdocuments from the text in the specified range and returns a SubDocument object.
Syntax
expression. AddFromRange
( _Range_
)
expression Required. A variable that represents a 'Subdocuments' collection.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Range | Required | Range object | The range used to create one or more subdocuments. |
Return value
SubDocument
Remarks
The Range argument 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.
Example
This example creates one or more subdocuments from the selection.
ActiveDocument.ActiveWindow.View.Type = wdMasterView
ActiveDocument.SubDocuments.AddFromRange Range:=Selection.Range
See also
Subdocuments Collection Object
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for