![]() |
#1
|
|||
|
|||
![]()
Hi,
I am in desparate need of some macro help. I an my collegues work on many files every day in Corel and these contain a certain amount of layers. The problem is that some of these files have a layer called "Thick" and some have a layer called "Thick". What I want to do is move selected object (curves etc.) to either layer, as either one or the other will exist. This is what I have as a very basic code... Code:
Sub Thick() ' Description: ' all selected to .25 black and moves to layer Thick Dim OrigSelection As ShapeRange Set OrigSelection = ActiveSelectionRange OrigSelection.MoveToLayer ActivePage.Layers("Thick") OrigSelection.SetOutlineProperties 0.009843, OutlineStyles(0), CreateRGBColor(0, 0, 0), , , , , cdrOutlineButtLineCaps, cdrOutlineRoundLineJoin End Sub The problem is if the layer is not called "Thick", but instead "THICK", I get an error. (You should also know that I have about 12 layers to sort out in this fashion). I guess an alternative might be to get a code that searches all my layers, and if there is one called "THICK", it will change it to "Thick" Please help ![]() |
#2
|
||||
|
||||
![]() Code:
Sub Thick() Dim OrigSelection As ShapeRange, L as layer ' fix layer names For Each L In ActiveDocument.Layers If L.Name <> "Thick" And StrComp(L.Name, "Thick", vbTextCompare) = 0 Then L.Name = "Thick" Next Set OrigSelection = ActiveSelectionRange OrigSelection.MoveToLayer ActivePage.Layers("Thick") OrigSelection.SetOutlineProperties 0.009843, OutlineStyles(0), CreateRGBColor(0, 0, 0), , , , , cdrOutlineButtLineCaps, cdrOutlineRoundLineJoin End Sub |
#3
|
||||
|
||||
![]()
Here is another alternative:
Code:
Option Explicit Private Function FindLayer(ByVal p As Page, ByVal strName As String) As Layer Dim lyr As Layer Dim lyrFound As Layer Set lyrFound = Nothing For Each lyr In p.Layers If StrComp(lyr.Name, strName, vbTextCompare) = 0 Then Set lyrFound = lyr Exit For End If Next lyr Set FindLayer = lyrFound End Function Sub Thick() With ActiveSelectionRange .MoveToLayer FindLayer(ActivePage, "Thick") .SetOutlineProperties 0.009843, OutlineStyles(0), CreateRGBColor(0, 0, 0), , , , , cdrOutlineButtLineCaps, cdrOutlineRoundLineJoin End With End Sub |
#4
|
|||
|
|||
![]()
Excellent, thanks guys!
It's those magic bits of code that make the difference. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copy Selected Objects to new page maintaining layers | knowbodynow | CorelDRAW/Corel DESIGNER VBA | 5 | 07-03-2007 09:49 |
::LayerControl:: macro for FAST layer management in CorelDraw | wOxxOm | CorelDRAW/Corel DESIGNER VBA | 0 | 10-05-2006 12:40 |
Deselect all selected objects | Alex | FAQ | 1 | 16-05-2005 15:10 |
Objects won't move... | ddonnahoe | CorelDRAW/Corel DESIGNER VBA | 2 | 07-02-2005 08:16 |
VBA help needed - changing colours | fremoikaner | CorelDRAW/Corel DESIGNER VBA | 1 | 18-11-2004 07:06 |