When I''m designing in CorelDRAW (2017) I always end up grouping stuff together.For example, I always design symbols in CorelDraw and group the individual objects in one group, so I can copy them and change the color.
Now rather than export each individual symbol (group), I really want a macro which exports each selected symbol (group) as a PNG file with the file name the same as the group name.For example I have 5 symbols (groups) named: group1, group2, group3, group4, group5.And when I select only the first 3, I want to run a macro that exports each of those groups as an individual png file with the groupname as the file name (group1.png, group2.png and group3.png).
So far I can loop through each selected group and get the name.But now I need to export each of them as an image (png).
It seems I'm unable to do that.I''m only able to export all the selected group as one single image.
I use the 'Shape' object (Visual Basic) for each of the groups.Is there a way to export that 'Shape' object?
See my code below:
try code below
Sub exportGroups()Dim groups As ShapeRangeDim group As ShapeDim groupname As String, path As StringSet groups = ActiveSelectionRange
For i = 1 To groups.Countgroupname = groups.Shapes(i).Namegroups.Shapes(i).CreateSelectionpath = "c:\" & groupname & ".png"Set expflt = ActiveDocument.ExportBitmap(path, cdrPNG, cdrSelection, cdrRGBColorImage, 0, 0, 300, 300, cdrNormalAntiAliasing, False, True, True, False, cdrCompressionNone)With expflt.interlaced = True.Transparency = 0.invertmask = False.Color = 0.FinishEnd WithNext iEnd Sub
Thank you very much.I tested it out and needed some adjusmtents (different path).
But it end up working perfectly.I really appreciate your support, thanks!
So for the summary I have some screenshots of some symbol examples below this explanation.In short, my goal is to export every single group as an individual image file with it's group name as the file name.
1: Creation of some symbols grouped together (6 symbols, so 6 groups), with ontthe right side the group names changed to distinctive names.
2: Select all the symbols you want te export (in this case all 6) and run the macro, which is responsible for the export.
3: The exported result should be something like this.
4: The CorelDRAW macro I created and refined with the help of Mek made this possible.
This macro grabs all the selected groups on gets all the group name of each single group. It will export all the groups (1 by 1) to a directory and a file name (with the group name as the filename and a hardcoded directory).
You can retype this macro and change the path (directory) to a path that exists on your computer.In the future I want to expand this macro by implememting this in a user form, so I can select in a user interface which directory (path) I want to export and what extension (png or jpg of something else) I want. At the moments it export all images as png files with transparancy on.
Try it out and experiment.In this topic I will update my future, expandend macro.
Hi, maybe you can help me, but it only export te last group, if I change te name of the group it does work, but i always work with defaul group´s name. I appreciate any help. PD: My Corel is in spanish.
each group eyxported and saved to file. If all groups have same name then the output file is overwritten and at the end you see only one file exported (with last group).
Try change code as follow:
For i = 1 To groups.Countgroupname = groups.Shapes(i).Namegroups.Shapes(i).CreateSelectionpath = "c:\" & groupname & "_" & i & ".png"Set expflt = ActiveDocument.ExportBitmap(path, cdrPNG, cdrSelection, cdrRGBColorImage, 0, 0, 300, 300, cdrNormalAntiAliasing, False, True, True, False, cdrCompressionNone)With expflt.interlaced = True.Transparency = 0.invertmask = False.Color = 0.FinishEnd WithNext iEnd Sub
WOW! AMAZING! really really thanks!
You are welcome!