Hello,
Attached is an image of the export options I want to execute with my macro. This is my function and it's ingnoring the palette options. Anyone who can I help me? Image has to be png, transparent,t 8 bit.
Public Sub Export8Bit(ByVal filepath As String, ByVal filename As String, ByVal selectionRange As ShapeRange, ByVal scaleFactor As Double) Dim opt As New StructExportOptions Dim x As Double Dim y As Double Dim pal As New StructPaletteOptions ActiveDocument.Unit = cdrPixel opt.AntiAliasingType = cdrNormalAntiAliasing opt.ImageType = cdrRGBColorImage opt.Overwrite = True opt.ResolutionX = 96 opt.ResolutionY = 96 opt.Transparent = True opt.UseColorProfile = False opt.MaintainAspect = True pal.DitherType = cdrDitherFloyd pal.NumColors = 128 pal.PaletteType = cdrPaletteOptimized pal.DitherIntensity = 100 Set selectionRange = DeleteGuidelines(selectionRange) selectionRange.CreateSelection selectionRange.GetSize x, y opt.SizeX = x * scaleFactor opt.SizeY = y * scaleFactor ActiveDocument.Export filepath & filename & ".png", cdrPNG, cdrSelection, opt, palEnd Sub
Hope this helps
Sub TestProgram()
Dim filepath As StringDim filename As StringDim shR As ShapeRangeDim ScaleFac As Doublefilepath = "C:\Users\chris\Desktop\Corel Draw VBA Snippets\Test Program\"filename = "Test PNG"Set shR = ActiveSelectionRangeScaleFac = 0.1Export8Bit filepath, filename, shR, ScaleFac
End Sub
Public Sub Export8Bit(ByVal filepath As String, ByVal filename As String, ByVal selectionRange As ShapeRange, ByVal scaleFactor As Double)
Dim opt As New StructExportOptions Dim x As Double Dim y As Double Dim pal As New StructPaletteOptions Dim flt As ExportFilter ActiveDocument.Unit = cdrPixel opt.AntiAliasingType = cdrNormalAntiAliasing opt.ImageType = cdrPalettedImage 'opt.ImageType = cdrRGBColorImage opt.Transparent = True opt.Overwrite = True opt.ResolutionX = 96 opt.ResolutionY = 96 opt.UseColorProfile = False opt.MaintainAspect = True
pal.DitherType = cdrDitherFloyd pal.NumColors = 128 pal.PaletteType = cdrPaletteOptimized pal.DitherIntensity = 100
'Set selectionRange = DeleteGuidelines(selectionRange) This causes an error, is it a private function? selectionRange.CreateSelection selectionRange.GetSize x, y opt.SizeX = x * scaleFactor opt.SizeY = y * scaleFactor 'ActiveDocument.Export filepath & filename & ".png", cdrPNG, cdrSelection, opt, pal
'I used the ExportEx method and created a variable flt as ExportFilter Set flt = ActiveDocument.ExportEx(filepath & filename & ".png", cdrPNG, cdrSelection, opt, pal)
'The Finish method completes the export process. flt.Finish
'When you set something it is a good idea to eliminate it from memory when done Set flt = NothingEnd Sub