![]() |
#1
|
|||
|
|||
![]()
Hello,
I need a quick way to get all the colors in a document. Right now I've revised the code for replace colors to create a list of colors, but this process takes a bit when there are a lot of objects. I've found the palette object which has a createfromdocument function which gets all the colors and puts them in a palette, but I don't want to save the palette. If anybody has any advice in this matter, I'd appreciate your time. Thanks, Mike |
#2
|
|||
|
|||
![]()
Man, I need exactly the same thing. There was a version for ver. 9 but I'm using 10. I don't know the VB end of this, but if that one could be modified to run on version 10, that'd be great.
|
#3
|
||||
|
||||
![]()
Mike,
Your best bet would be to use Palettes.CreateFromDocument, extract the color information from the palette, then close it and delete the created palette file: Code:
Public Sub GetColorInformation() Dim c As Color Dim pal As Palette Dim sFileName As String Set pal = Palettes.CreateFromDocument("Dummy", "C:\Temp\Dummy.cpl") sFileName = pal.FileName For Each c In pal.Colors ' ... Do something to the colors ... Next c pal.Close Kill sFileName End Sub |
#4
|
|||
|
|||
![]()
Sorry to bump such an old thread, but this seems on-topic:
This method works nicely for the colors in the document or selection, but how to access the default, built-in palettes through VBA? Like the Default CMYK palette shown here: ![]() Didn't find their files in any directory and they are not part of the "Fixed" ones which could be loaded either. Any suggestions? |
#5
|
|||
|
|||
![]()
If you right-click one of the colors for a few seconds and select pallete>save as... it will show you where it is saved. In my system : C:\Documents and Settings\Compaq_Owner\Application Data\Corel\CorelDRAW Graphics Suite X4\User Custom Data\Palettes
|
#6
|
|||
|
|||
![]()
Yes it would. You may however notice that there is no such Palette by default since that is the custom user Palette directory.
Of course I could just save the default one there (by hand) and then load it (using VBA), but I'd prefer to make something that just works without any extra steps. Edit: Digging a little deeper - if you would execute this code: Code:
Sub PalTest() For Each pal In Palettes Debug.Print pal.PaletteID Next pal End Sub Code:
Set pal = Palettes.OpenFixed(5) |
![]() |
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 |
Palette (or Colors array) property in VBA class in CDR12 | zlatev | CorelDRAW/Corel DESIGNER VBA | 7 | 22-02-2005 11:28 |
Creating new document problems | ddonnahoe | Code Critique | 2 | 20-11-2004 17:11 |
Wish to Convert Named Colors to Shape Color | D_Green | CorelDRAW/Corel DESIGNER VBA | 1 | 12-09-2004 11:08 |
Paste and Undo List problem | Michael Cervantes | Corel Photo-Paint VBA | 5 | 11-09-2004 04:47 |
Active document issues.. | wbochar | CorelDRAW/Corel DESIGNER VBA | 2 | 19-03-2003 15:15 |