Hello. Reasonably-experienced VBA programmer in Word & Excel, but this has me stumped, because of a behavior change between X4 and X8.
Platform: Win10/64, with all patches. 32Gb of RAM. CorelX8 with all patches.
I wrote a macro in X4 to export a selected object to .png. I usedstrFilename = CorelScriptTools.GetFileBox(Filter:="*.png", Title:="Export as .png", Type:=1, file:=strFilename, extension:="png", folder:=strDocpath, button:="Save")
strFilename = CorelScriptTools.GetFileBox(Filter:="*.png", Title:="Export as .png", Type:=1, file:=strFilename, extension:="png", folder:=strDocpath, button:="Save")
to specify the filename and target folder, andActiveDocument.Export strFilename, cdrPNG, cdrSelection
ActiveDocument.Export strFilename, cdrPNG, cdrSelection
to execute the save. That all worked very well and I took it as a victory of human ingenuity over modern technology.
In X8, I had to twiddle the CorelScriptTools code a bit, but the CorelScript file dialog still functions as expected, loading the variable strDocpath with the desired directory and strFilename with the specified file name.
However — and this is the new behavior in X8,
instead of silently writing the .png and the macro exiting, now launches another dialog having none of the parameters specified in the "command tail" of the ActiveDocument.Export object and defaulting to the Documents folder and .pdf as the file format.
This is weird. If there's another way to do this, I'm open to suggestions. Is there a different way of launching a Save dialog that works around this behavior in ActiveDocument.Export?
Thanks, in advance, for any insight into this changed behavior.
I don't know if it suits your needs, but you might try my Quick Export macro.
I can't address the question of how your code is behaving, as I haven't tried doing it that way. In my macro, I go about it a bit differently, using an ExportFilter object.