API Documentation > CorelDRAW > 2025-v26 > Application > IVGApplication
Application.ActiveDocument property
Gets the reference to the currently active document
Syntax:
Property Get ActiveDocument() As Document
Remarks:
The ActiveDocument property returns a read-only reference to the active document. You do not need to activate a document before working with it in CorelDRAW. The document stays inactive, but you still can work with it. For example, consider the following code example: [code] Documents(1).Activate ActiveDocument.AddPages 1 [/code] The preceding code example produces the same result as the following code example: [code] Documents(1).AddPages 1 [/code] Both of these examples add a new page to the first open document, which is the first document.
Examples:
The following VBA example creates a new document and draws an ellipse in it. Then another document is created, and a rectangle is added to it. The first document is then activated and a new page is added to it.
Sub DocumentActive()
CreateDocument
ActiveLayer.CreateEllipse2 3, 2, 1
CreateDocument
ActiveLayer.CreateRectangle 2, 3, 4, 5
Documents(1).Activate
ActiveDocument.AddPages 1 
End Sub