Sporadic Issues Exporting from Macros with Corel 2023

At my company we have a macro that exports a bitmap into .psd format and opens it in Photoshop. This has worked perfectly in previous versions of CorelDraw but we are now getting sporadic issues where the export fails. Sometimes there is an unhelpful HRESULT error and sometimes the app hangs. In either case, the file is locked to the CorelDraw process and we need to kill the process in order to delete the file. Sometimes CorelDraw crashes.

I did see this question: https://community.coreldraw.com/sdk/f/coreldraw-and-corel-designer-api/65792/corel-2022-exportbitmap-to-psd-is-broken-in-net/312227#312227

However, we are now on the latest version and there has been no improvement to the situation.

As I said, this was never an issue in past versions so I do not believe our macro code is causing the issues, but here is the macro code:

Dim strPSDfile As String
strPSDfile = "C:\Temp\" & docCorelDraw.FileName & "_edit.psd"

Dim ExportImage As ExportFilter
Set ExportImage = docCorelDraw.ExportBitmap(strPSDfile, cdrPSD, cdrSelection, cdrRGBColorImage, objImage.Bitmap.SizeWidth, objImage.Bitmap.SizeHeight, objImage.Bitmap.ResolutionX, objImage.Bitmap.ResolutionY, , , True)

ExportImage.Finish ' This call fails sometimes