Export selection as png using javascript

Hi,

I am trying to export selection to PNG file using simple javascript in CorelDraw 2019:

var opt = host.StructExportOptions;
opt.AntiAliasingType = host.cdrNormalAntiAliasing//getting error: Cannot set property 'AntiAliasingType' of undefined
opt.ImageType = host.cdrRGBColorImage;
opt.Overwrite = true;
opt.ResolutionX =300;
opt.ResolutionY = 300;
exportFileName = "d:\\test.png";
host.ActiveDocument.Export(exportFileName,host.cdrPNGhost.cdrSelectionoptundefined);
on the second line, I get error: Cannot set property 'AntiAliasingType' of undefined. Lines below it starting with opt will produce a similar error.
Please help in refining the code. Thanks in advance.
Parents Reply Children