Global.ActiveDocument Property (Word)

Returns a Document object that represents the active document (the document with the focus). Read-only.


expression. ActiveDocument

expression A variable that represents a 'Global' object.


If there are no documents open, using this property causes an error.


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

If Application.Documents.Count >= 1 Then 
 MsgBox ActiveDocument.Name 
 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.

Dim rngTemp As Range 
Selection.Collapse Direction:=wdCollapseStart 
Set rngTemp = 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.

Dim rngTemp As Range 
Set rngTemp = ActiveDocument.Range(Start:=0, End:=0) 
With rngTemp 
 .InsertBefore "Company Report" 
 .Font.Name = "Arial" 
 .Font.Size = 24 
End With 

See also

Global Object