Hi. Is there a macro that check a document after importing a file if there are added layers besides Layer 1. I keep running into a problem where five additional layers are made after importing an ai file.
You could make such a macro but you'll still need to run it manually not run automatically on import. Import then run the macro or add the macro icon to the toolbar for a quick click.
Best I can come up with is adding the layer count into the title bar. If the count is more than 2 you know you might have "problems"
Alternately you could make a macro that will move all shapes to Layer 1 then delete any empty layers. But you'd still need to run it each time after import.
is there a macro that does this?
try this
Sub FlattenLayersUltra() Dim sr As ShapeRange, s As Shape, pg As Page, lyr As Layer Optimization = True ActivePage.Shapes.All.AddToSelection Set sr = ActiveSelectionRange For Each s In sr s.Layer = ActivePage.Layers("Layer 1") Next s For Each pg In ActiveDocument.Pages For Each lyr In pg.Layers If Not lyr.IsSpecialLayer Then Set sr = lyr.Shapes.All If sr.Count = 0 Then lyr.Delete End If End If NextNextOptimization = FalseActiveWindow.RefreshRefreshActivePage.Layers("Layer 1").ActivateEnd Sub
oops. not sure why but it crashed CorelDraw when I ran it.
tried it again after restart and it works. Any chance to run this thru all pages?
when you get a chance, could you test this file? Use the macro on page one and check all pages. something is wrong.
https://www.dropbox.com/s/9wsn9py47bzed3w/layer%20test_3.cdr?dl=0
I'm not using CGS 2019. Still on X7 here so I can't test the file. Yes, it would have to be edited to run thru all pages.