Content Property

Microsoft Word Visual Basic

Show All

Content Property

       

Returns a Range object that represents the main document story. Read-only.

Remarks

The following two statements are equivalent:

Set mainStory = ActiveDocument.Content
Set mainStory = ActiveDocument.StoryRanges(wdMainTextStory)

Example

This example changes the font and font size of the text in the active document to Arial 10 point.

Set myRange = ActiveDocument.Content
With myRange.Font
    .Name = "Arial"
    .Size = 10
End With

This example inserts text at the end of the document named "Changes.doc." The For Each...Next statement is used to determine whether the document is open.

For Each aDocument In Documents
    If InStr(LCase$(aDocument.Name), "changes.doc") Then
        Set myRange = Documents("Changes.doc").Content
        myRange.InsertAfter "the end."
    End If
Next aDocument