Shaddy Dedmore
06-12-2005, 3:14 AM
Here's some VBA code that I came up with to change line colors of objects.
Every time I try to save it as a lesser cdr (like ver 11) I lose the VBA... so i thought I'd just post the code.
Let me know if you can't see it and we'll try something else.
Usage: If you have a number of objects with multiple
line colors, let's say red, black and green. And they're
all mixed together, even overlapped. Now you want to
change all the red ones to yellow. Could be a lot of
clicking. Run this using the following steps to change
all the red to yellow...
it's multi-stepped, here's the instructions...
Easiest way I could find to add code manually, is to:
Step 1 - open the VBA editor (alt-F11 in ver 12)
Step 2 - Click on INSERT == MODULE within VB
Step 3 - Paste in the code below
Then to run the macro...
Step 1 - Well, run the VBA code, it's called Macro1 in this case.
TOOLS == VISUAL BASIC == PLAY
Choose Macro1 (unless you renamed it)
Step 2 - Select one Red object by clicking on it
Step 3 - Choose new color (yellow in my example) from popup
Step 4 - Click and drag a Rectangle that will include all of the
red objects that you want to change to yellow.
If you need to scoll, run it multiple times, it's a one shot thing
Hopefully this works so you can cut and paste without having problems with word wrapping.
Sub Macro1()
Dim c As New Color
Dim c2 As Color
Dim d As Document
Dim sel As Shape, s As Shape
Dim sel2 As Shape
Dim b As Boolean
Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double, Shift As Long
Set d = ActiveDocument
b = True
While b = True
MsgBox "Select 1 object that has the color that you want to replace." & vbCrLf & vbCrLf & "The step after that is to pick the new color"
NothingSelected:
d.GetUserClick x1, y1, Shift, 100, True, cdrCursorPick
Set sel = d.ActivePage.SelectShapesAtPoint(x1, y1, False)
If sel.Shapes.Count = 0 Then
MsgBox "No object selected, please select again"
GoTo NothingSelected
End If
Set c2 = sel.Outline.Color
c.UserAssign
MsgBox "Click and Drag bounding rectangle to select objects that you want to change color"
NothingSelected2:
d.GetUserArea x1, y1, x2, y2, Shift, 100, False, cdrCursorWinCross
Set sel2 = d.ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
If sel2.Shapes.Count = 0 Then
MsgBox "No object selected, please select again"
GoTo NothingSelected2
End If
For Each s In sel2.Shapes
If s.Outline.Color.IsSame(c2) Then
s.Outline.Color = c
End If
Next s
b = False
Wend
End Sub
Every time I try to save it as a lesser cdr (like ver 11) I lose the VBA... so i thought I'd just post the code.
Let me know if you can't see it and we'll try something else.
Usage: If you have a number of objects with multiple
line colors, let's say red, black and green. And they're
all mixed together, even overlapped. Now you want to
change all the red ones to yellow. Could be a lot of
clicking. Run this using the following steps to change
all the red to yellow...
it's multi-stepped, here's the instructions...
Easiest way I could find to add code manually, is to:
Step 1 - open the VBA editor (alt-F11 in ver 12)
Step 2 - Click on INSERT == MODULE within VB
Step 3 - Paste in the code below
Then to run the macro...
Step 1 - Well, run the VBA code, it's called Macro1 in this case.
TOOLS == VISUAL BASIC == PLAY
Choose Macro1 (unless you renamed it)
Step 2 - Select one Red object by clicking on it
Step 3 - Choose new color (yellow in my example) from popup
Step 4 - Click and drag a Rectangle that will include all of the
red objects that you want to change to yellow.
If you need to scoll, run it multiple times, it's a one shot thing
Hopefully this works so you can cut and paste without having problems with word wrapping.
Sub Macro1()
Dim c As New Color
Dim c2 As Color
Dim d As Document
Dim sel As Shape, s As Shape
Dim sel2 As Shape
Dim b As Boolean
Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double, Shift As Long
Set d = ActiveDocument
b = True
While b = True
MsgBox "Select 1 object that has the color that you want to replace." & vbCrLf & vbCrLf & "The step after that is to pick the new color"
NothingSelected:
d.GetUserClick x1, y1, Shift, 100, True, cdrCursorPick
Set sel = d.ActivePage.SelectShapesAtPoint(x1, y1, False)
If sel.Shapes.Count = 0 Then
MsgBox "No object selected, please select again"
GoTo NothingSelected
End If
Set c2 = sel.Outline.Color
c.UserAssign
MsgBox "Click and Drag bounding rectangle to select objects that you want to change color"
NothingSelected2:
d.GetUserArea x1, y1, x2, y2, Shift, 100, False, cdrCursorWinCross
Set sel2 = d.ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
If sel2.Shapes.Count = 0 Then
MsgBox "No object selected, please select again"
GoTo NothingSelected2
End If
For Each s In sel2.Shapes
If s.Outline.Color.IsSame(c2) Then
s.Outline.Color = c
End If
Next s
b = False
Wend
End Sub