Library tutorials & articles

Manipulate CorelDraw layers

Introduction

I started working with CorelDraw! 9.0 about 2 years ago, and found some practical functions were missing. Therefore, I have added these functions using VBA. I will post more subs and functions soon.

Contents

Page 2 - LayerExists - Check if a layer exists

Page 3 - LayerCreate - Corel VBA provides a function for adding layers, but that one reports an error when the layer already exists and stops the code.

Page 4 - LayerActive - This one is also available in Corel, but the same as LayerCreate, Corel doesn't check first if the layer exists...

Page 5 - LayerSingle - Very practical when you've got a lot of layers and want to edit or export only objects on one of them...

Any comments or suggestions? Please contact me!

All my posted Corel VBA subs and functions are for FREE, just let me know if this helped you in any way... and include me on the credits list when you start distributing ;-)

Have fun!

Comments

  1. 16 Apr 2004 at 05:23
    hi there, i am from Turkiye Izmir, graphic illustrator and musician..

    i am interesting and doin something over corel vba (assembling, converting, contact sheet etc)
    if u interes too, we can share our knowledge. take care...


    my contacts are;
    icq: 92073130
    mail: cornellius4@hotmail.com ( also msn messenger )
  2. 31 Mar 2004 at 08:53

    Dear thamar




    Als ik naar http://www.developerfusion.com/show/2657/2/ eerste hit op google... ga en onderstaande code gebruik dan krijg ik een foutmelding


    'Check if layer exists
    Public Function LayerExists(varLayerName As String)


    Set myDoc = Application.ActiveDocument
    LayerExists = False
    For Each Layer In myDoc.ActivePage.Layers
    If Layer.Name = varLayerName Then LayerExists = True
    Next


    End Function


    Foutmelding:


    (2) Fout: Syntaxisfout bij symbool "FUNCTION".
    (4) Fout: Syntaxisfout bij symbool "MYDOC".
    (4) Fatale fout: Dialoogvenster of dialoogbesturing niet gespecificeerd.
    3 fouten(en), 0 waarschuming(en).


    Als ik "As String" weglaat verdwijnt de fout op regel 2 klopt dit qua syntax?
    rest van fouten blijft, kan ik deze syntax gebruiken in CorelDraw9?




    Ik wil de code gebruiken in onderstaande script om layers uit te schakelen en dan te printen.




    'Check if layer exists
    Public Function LayerExists(varLayerName As String)
    Set myDoc = Application.ActiveDocument
    LayerExists = False
    For Each Layer In myDoc.ActivePage.Layers
     If Layer.Name = varLayerName Then LayerExists = True
    Next
    End Function






    WITHOBJECT "CorelDraw.Automation.9"


               'Print "Supplier" = Set Layer Customer "On"


               BMS_PageMax=.GetPageCount()


               BMS_PageCount=1


               Do while BMSpageCount <= BMSPageMax


               


               if not LayerExists("Assembly_Customer") THEN


                           .NewLayer "Assembly_Customer"


                           .SetLayerVisible 0, "AssemblyCustomer", BMSPageCount


                           .SetLayerPrintable 0, "AssemblyCustomer", BMSPageCount


               elseif LayerExists("Assembly_Customer") THEN


                           .SetLayerVisible 0, "AssemblyCustomer", BMSPageCount


                           .SetLayerPrintable 0, "AssemblyCustomer", BMSPageCount


               endif                


               if  LayerExists("Header_cus") THEN


                           .NewLayer "Header_cus"


                           .SetLayerVisible 0, "Headercus", BMSPageCount


                           .SetLayerPrintable 0, "Headercus", BMSPageCount


               elseif .SelectLayer("Header_cus")  = -1 THEN


                           .SetLayerVisible 0, "Headercus", BMSPageCount


                           .SetLayerPrintable 0, "Headercus", BMSPageCount


               endif


               'Set Layer Supplier "Off"


               if   LayerExists("Assembly_Supplier") THEN


                           .NewLayer "Assembly_Supplier"


                           .SetLayerVisible -1, "AssemblySupplier", BMSPageCount


                           .SetLayerPrintable -1, "AssemblySupplier", BMSPageCount


               elseif .SelectLayer("Assembly_Supplier") = -1 THEN


                           .SetLayerVisible -1, "AssemblySupplier", BMSPageCount


                           .SetLayerPrintable -1, "AssemblySupplier", BMSPageCount


               endif


               PageCount=PageCount+1


               Loop                


               .FilePrint


    END WITHOBJECT




    With kind regards,




    Beuvema

  3. 01 Jan 1999 at 00:00

    This thread is for discussions of Manipulate CorelDraw layers.

Leave a comment

Sign in or Join us (it's free).

 tlosekoot I was born in a small town in Holland, and currently live in Poland. I'm fluent in English, German, Polish and Dutch, speak a bit of French and Russian. After finishing Information Technologies in ...

We'd love to hear what you think! Submit ideas or give us feedback