Hello
I am using CorelDRAW API within my VBA Application since years.For easier compiling and different version issues I recently changed from early to late binding. So now there is no reference to CorelDRAW.tlb necessary. After rebuilding hundreds of subs/functions everything works fine. But at the end, when exporting a document, the error 13 "type missmatch" occurs. I made many tests but could not find a problem in my code. Maybe this is a bug in the API itself?
Below a simple code, which could be tested in CorelDRAW VBA. From my point of view this code should normally work.
Private Sub Test_ExportEx_oDoc_as_Object() 'Late Binding Dim oApp As Object Dim oDoc As Object Dim oExpOpt As Object Dim oExpFlt As Object Dim sFile As String Set oApp = Application Set oDoc = oApp.ActiveDocument Set oExpOpt = oApp.CreateStructExportOptions oExpOpt.UseColorProfile = True sFile = "C:\temp\Test.eps" Set oExpFlt = oDoc.ExportEx(sFile, cdrEPS, cdrCurrentPage, oExpOpt) With oExpFlt .Finish End With End Sub
Has anybody experienced the same problem or a workaround? Please also respond if you can confirm, that this is likely might be a problem of the API itself.
I tried this with X7 and 2020.
Best RegardsKlaus
Hello FaneDuru
Thank you for your very helpfull comments!! Yes I do use it outside Corel within an Access VBA. Beside other things, with this Application I do also automatise almost everything like SAP, CorelDRAW, PHOTOPAINT, almost all Office 365 Apps and others. Now, if you use early binding you have to set references to almost all of these Apps. A client who does not have all referenced Applications installed lead to broken references and that has also a bad effect to the rest of the App. Having late bindung, everything works and you can exclude some modules/functionalities "on-the-fly" for that client.
It is also correct that you have to define all needed Corel ENUMs manually for late binding. To make the Test Sub as simple as possible, I just tried it within Corel VBA....
If you use conditional compiling within your code you can still use intellisense for programming. This makes programming a bit more complicated, but without intellisense programming with these many APIs would be almost not possible.
But, your comment about a missing parameter was very very helpfull! However the missing 5th parameter is the PaletteOptions and due to documentation (Document.ExportEx method - Developer Area - CorelDRAW Community) this parameter is optional. Due to that I have not even thought about adding this parameter. I also never recognised such a different behavior with other API and also with other COREL functions.
I have already added the PaletteOptions Parameter in my App and now also the ExportEx function works.
Thank you very much for that hint!!