I'm developing a macro/application in VB.NET to perform some operations on the currently open document in CorelDRAW (2018 version). I'm trying to use the following code to use GetActiveObject()
to acquire a reference to the currently open instance of Corel:
Dim ActiveCorelApp As Corel.Interop.VGCore.Application = Nothing
Try
ActiveCorelApp = System.Runtime.InteropServices.Marshal.GetActiveObject("CorelDRAW.Application.20")
Catch ex As Exception
MsgBox("Error4: Could not get the active CorelDRAW.Application object. Make sure CorelDRAW is running.")
End Try
This application is currently using the exact same method to acquire references to both Autodesk Inventor and AutoCAD with no issues.
I have found references to running both the target application (Corel in this case) and Visual Studio in administrator mode fixing this problem. However no combination of running Visual Studio and/or Corel in administrator mode made a difference.
I have tried many different object name strings, but after checking in the registry it appears that "CorelDRAW.Application.20"
is correct.
I downloaded an ROT (Running Objects Table) viewer and Corel does not show up on the list. It seems (according to other forum posts) that certain programs have trouble registering with the ROT immediately after startup and require that the application lose window focus and regain it before it will register. Performing similar actions (minimize/restore, switching to another program and back) on CorelDRAW have had no effect.
The exact error I'm getting is this:
System.Runtime.InteropServices.COMException: 'Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))'
User contributions licensed under CC BY-SA 3.0