app.Visible = True
Shows the CDR window. Setting it False is faster for batch runs, but keep it True while debugging so you can see what actually happened.
Signature
Notes
Python example (runnable)
pywin32. The example assumes app / doc / page / layer are already connected.
See Connection & Initapp.Visible = True # True = show the UI, so you see each step (keep it on while debugging)
# app.Visible = False # False = hidden, faster, but you cannot see failures
print("Visible: ", app.Visible)
It controls the application window, not document windows
app.Visible is an application-level property: it shows or hides the CorelDRAW main
window. It does not open a document, and it does not bring a particular document window forward —
that is the job of the window objects under doc.Windows.
The two opposite problems people hit
Problem one: no window, but the process exists. An instance started through COM
can come up minimised or behind everything. Dispatch succeeds, app.Version
reads fine, and the screen shows nothing, so you assume you attached to a phantom object. Set
app.Visible = True first, then go look at Task Manager.
Problem two: windows flashing, user interrupted. In unattended batch work, showing
the window is slower (every step repaints) and, if someone else is using that machine, it keeps
stealing focus. That case wants False.
What to do when it is visible but still behind
Visible = True guarantees "shown", not "brought to front". Two approaches:
- Try the application's own window object — some versions expose
app.AppWindow, from which you can callActivate. Whether that property exists and what the method is called varies by version, so inspect it withdir()rather than hard-coding. - More reliable: let the OS do it. Find the window by title with
win32guiand callSetForegroundWindow. It does not depend on CorelDRAW's automation surface and works across versions.
Keep the perspective though: a background script stealing focus is bad behaviour by default. The legitimate case is you debugging and wanting to see what it is doing. Do that temporarily; do not ship it.
The real cost of setting it to False
Hiding the window does save repaint work, but it is not risk-free. These change behaviour when the application is invisible: anything that depends on a dialog (export options, font substitution prompts, missing-link prompts), some render paths that need a window handle, and properties computed from window dimensions. The failure mode is rarely a clean exception — it is a property that reads back as 0, or a call that waits forever for a dialog nobody will ever see.
So the safe order in batch work: get the whole pipeline correct with Visible = True,
then flip it to False and run it again to see which steps slow down or return odd values.
Do not debug with it hidden. Errors produced in an invisible session cost several
times more to diagnose than the same errors with the window on screen.
Setting it and immediately calling into it
When Dispatch returns, the process exists, but the main window's message pump may not
be ready. Fire a heavy operation straight away and you will occasionally get "object not available".
The pragmatic readiness check is to read a property that must return something:
import time
import win32com.client
app = win32com.client.Dispatch("CorelDRAW.Application")
app.Visible = True
for _ in range(50): # up to 5 seconds
try:
n = app.Documents.Count # readable means the channel is live
break
except Exception:
time.sleep(0.1)
else:
raise SystemExit("CorelDRAW started but never became ready - check for a modal dialog")
print("ready, open documents:", n)
This beats a flat time.sleep(10): no wasted time on fast machines, and no shortfall on
slow ones.
Typical usage
import win32com.client
app = win32com.client.Dispatch("CorelDRAW.Application")
# interactive debugging: show the window so you can watch it work
app.Visible = True
# unattended batch: use this instead, it cuts repaint work
# app.Visible = False
doc = app.CreateDocument()
print(doc.Name, doc.Pages.Count)
Details that trip people up
- Do not set it inside a loop. Every assignment changes window state and triggers extra repaints and messages. Set it once, outside.
- Visible does not fix "attached to the wrong instance". If
Dispatchlanded on another running instance, setting Visible just makes that instance appear — your later calls still go there. When in doubt, readapp.Versionandapp.ActiveDocumentto confirm what you are talking to. - Instances started with
-silentor as a service may ignore it. No interactive desktop means no window to show. That is session isolation, not a bug in your code. - It does not change export output. Visible or not, the files you export are identical; only speed and debuggability differ. People hide the window "to export faster" and then walk straight into the dialog-dependent paths above.
About this section: Connection & Init
Connection & Init — connecting to CorelDRAW over COM.
- This section has 8 entries; this is one of them.
- See the full section index: Connection & Init
Other entries in this section
- pythoncom.CoInitialize()COM initialization; it goes on the first line of the script. Any threa
- win32com.client.Dispatch("CorelDRAW.Application.21")Connect by version number; 21 is CorelDRAW 2019. If CDR is already run
- win32com.client.Dispatch("CorelDRAW.Application")No version number, so it binds to whatever version is registered as de
- win32com.client.GetActiveObject("CorelDRAW.Application.21")Attaches to an instance that is already open and never starts a new pr
- win32com.client.gencache.EnsureDispatch(progid)Once the constant cache exists you can write cdrTextShape instead of 6
- app.VersionReturns the version as a string. Use it to confirm which version you a
- app.Quit()Closes CorelDRAW entirely. Don't call it at the end of a batch job — i