I'm not hopeful, but is there by chance a way to export layers separately? i.e. if a PP project has say 10 layers am I able to export them as individual images? I know I can do it one at a time with the "export selected only" setting, but I'm looking for a way to do it all in one shot.
I hadn't tried this before, and make no claims that it's "good code", but this seemed to work OK for me in a couple of tests I tried in X7.
Sub save_layers_as_files()Dim index_counter As LongDim layer_name As StringDim orig_filenameDim saveas_filename As StringDim d As Documentorig_filename = ActiveDocument.FileNameFor index_counter = 1 To ActiveDocument.Layers.Count 'get layer name layer_name = ActiveDocument.Layers(index_counter).Name 'cook up new filename saveas_filename = "C:\Temp\" & orig_filename & "_" & layer_name & ".PNG" 'copy this layer ActiveDocument.Layers.Item(index_counter).Copy 'new document from clipboard Set d = Application.CreateDocumentFromClipboard 'saveas this document d.SaveAs(saveas_filename, cdrPNG).Finish 'close this document ActiveDocument.CloseNext index_counterEnd Sub
Note that, in the SaveAs, you get to select the export filter. In the code shown above, I made it PNG.
When doing the SaveAs, one can also use "StructSaveOptions" to set the details for how the export is carried out. I don't know the details of how to implement that, but I know that it exists.
pranderson said:Nice! I was trying something as well, but I didn't get as far as you did. Got hung up on how to use the layer name for the new filename. The macro "seems" to run fine, but where do the images save??? ...or where do I add the folder I want them in? I see it creates something in the Temp folder, but I'm clueless as to where the images went. Patti
It should be exporting the images right to that folder - C:\Temp. That's what it does on my system.
I tried to slick it up by using Application.CorelScriptTools.GetFolder to allow the user to browse to select the desired target folder. The GetFolder thing works for me in CorelDraw X7, but in Photo-Paint X7, it's throwing an error for me.
ETA: I found a post from Shelby Moore in the Developer Area confirming that it won't work, and offering some more sophisticated code as his suggested way to accomplish the folder browsing.
PJ said:Thanks for going to the trouble, Myron. How do I use this script?
In this thread, I tried to type out a quick description of how to get started with a macro in CorelDraw X7.
I don't know how close that is to Photo-Paint X6.