ActiveDocument Property

Applies To

Application object, Global object.

Description

Returns a Document object that represents the active document (the document with the focus). If there are no documents open, an error occurs. Read-only.

See Also

ActiveWindow property, Document object, Documents property.

Example

This example displays the name of the active document, or if there are no documents open, it displays a message.

If Documents.Count >= 1 Then 
    MsgBox ActiveDocument.Name
Else
    MsgBox "No documents are open"
End If
This example collapses the selection to an insertion point and then creates a range for the next five characters in the selection.

Selection.Collapse Direction:=wdCollapseStart
ActiveDocument.Range Start:=Selection.Start, End:=Selection.Start+5
This example inserts texts at the beginning of the active document and then prints the document.

Set myRange = ActiveDocument.Range(Start:=0, End:=0)
With myRange
    .InsertBefore "Company Report"
    .Font.Name = "Arial"
    .Font.Size = 24
    .InsertParagraphAfter
End With
ActiveDocument.PrintOut