Home/ Reference/ Application

app.ActiveDocument

The document in front. Returns None when nothing is open, so wrap it in try/except and fall back to CreateDocument.

Signature

app.ActiveDocument

Notes

The document in front. Returns None when nothing is open, so wrap it in try/except and fall back to CreateDocument.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
doc = None
try:
    doc = app.ActiveDocument            # the active document
except Exception:
    doc = None                          # returns nothing when no document is open

if doc is None:
    doc = app.CreateDocument()          # fall back to creating one

print("Active document: ", doc.FileName or "unsaved")

About this section: Application

Application — the CorelDRAW application object.

Other entries in this section