![]() |
#1
|
|||
|
|||
![]()
How can I reset the document colors with a macro?
I can cycle it on/off but can't figure out how to "reset" it. Once a color shape is deleted the doc palette still shows the color until you click thru and hit reset. Sub RefreshDocPalette() ActiveDocument.Palette.Close ActiveDocument.Palette.Open End Sub P.s. why after hitting "reset palette" does it add a black swatch even though there's no black used in the doc. |
#2
|
|||
|
|||
![]()
One suggestion is close but it deletes all the colors. As one is "doodling" lots of colors get added to the document coors palette. Even after you delete a bunch of different colored shapes. Manually hit reset and only the colors that exist in the document are displayed.
|
#3
|
|||
|
|||
![]()
Oops, forgot to add the suggestion
For i = ActiveDocument.Palette.Colors.Count To 1 Step -1 ActiveDocument.Palette.RemoveColor (i) Next i |
#4
|
|||
|
|||
![]()
Hi
If you programmatically delete shape then you can check if there are any other objects of the same color left. And then delete this color from palette |
#5
|
|||
|
|||
![]()
I've experimented with several scripts but can't seem to get it?
|
#6
|
|||
|
|||
![]() Code:
Sub DeleteColors() Dim s As Shape, c As Color Set s = ActiveShape: If s Is Nothing Then Exit Sub If s.Fill.Type <> cdrUniformFill Then Exit Sub Set c = s.Fill.UniformColor s.Delete 'delete selected shape 'looking for the same color For Each s In ActivePage.Shapes.All If s.Fill.Type = cdrUniformFill Then If c.IsSame(s.Fill.UniformColor) Then Exit Sub End If Next With ActiveDocument.Palette .RemoveColor .GetIndexOfColor(c) End With End Sub |
#7
|
|||
|
|||
![]()
That actually requires you to select all the shapes and then just deletes 1 shape.
|
#8
|
|||
|
|||
![]()
there is no need to select all the shapes. Macro deletes one selected shape and removes its color from the palette, if there are no more objects with the same color in current document.
if you want to delete several objects of different colors and remove their colors from the palette, then the macro needs to be slightly modified |
#9
|
|||
|
|||
![]()
I don't want to delete any shapes at all. I merely want the Document Colors to reflect only the colors currently used in the document. The Doc Color palette will show all colors ever used even after all shapes using that color are gone or changed.
The macro should "get color" of each shape and delete the colors from the Doc Palette that aren't currently in the doc. |
#10
|
|||
|
|||
![]()
try this:
Code:
Sub RemoveWasteColors() Dim c As Color, sr As New ShapeRange, srAllShapes As ShapeRange, s As Shape Set srAllShapes = ActivePage.Shapes.All For Each c In ActiveDocument.Palette.Colors For Each s In srAllShapes If s.Fill.Type = cdrUniformFill Then If c.IsSame(s.Fill.UniformColor) Then sr.Add s End If Next s If sr.Count > 0 Then srAllShapes.RemoveRange sr: sr.RemoveAll Else With ActiveDocument.Palette .RemoveColor .GetIndexOfColor(c) End With End If Next c End Sub |
![]() |
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 |
Getting a list of all colors in a Document | CORNMEN | CorelDRAW/Corel DESIGNER VBA | 5 | 15-11-2008 06:14 |
List the Colors Used in a Document | designhouse | CorelDRAW/Corel DESIGNER VBA | 1 | 16-10-2007 03:36 |
How to find out what colors are used in a document? | Alex | FAQ | 1 | 16-04-2007 22:07 |
Minimizing the number of colors used in a document | Alex | FAQ | 1 | 24-05-2005 11:46 |
How to convert my document colors to grayscale | Alex | FAQ | 1 | 03-05-2005 15:55 |