Library tutorials & articles
Manipulate CorelDraw layers
- Introduction
- LayerExists
- LayerCreate
- LayerActive
- LayerSingle
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!
Related articles
Related discussion
-
How to control IE from VBA
by NaseemAhmed (0 replies)
-
Excel 2007 Error : ' the digital signature is deleted when Excel users tries to save the Master Excel Spreadsheet.'
by jdierkes (0 replies)
-
Excel VBA transposition problem
by KDHTSVAU (2 replies)
-
excell question
by Uncle (11 replies)
-
Question about subforms
by ginwah (0 replies)
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 )
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
This thread is for discussions of Manipulate CorelDraw layers.