Excel VBA failing to access CorelDraw Page property with Late Binding

68 Views Asked by At

I have an Excel (Office 16) VBA code that opens a CorelDraw document and performs a task based on the orientation of each page in the document. The code is as follows:

Dim app As Object
Dim page As Object

Set app = CreateObject("CorelDRAW.Application")
app.OpenDocument "xxx.pdf"

For Each page In app.ActiveDocument.Pages
If page.Orientation = cdrLandscape Then
...
End If
Next

The code fails to execute the "If" statement, even though I can see the orientation property of the page in the Locals window. What is wrong here? (late binding is a necessary condition in this case)

1

There are 1 best solutions below

0
On

cdrLandscape needs to be declared in your code if you're using late binding, or you can substitute the numeric value (1)