OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 24-06-2003, 10:43
CORNMEN
Guest
 
Posts: n/a
Default Getting a list of all colors in a Document

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
Reply With Quote
  #2  
Old 24-06-2003, 14:07
Gilbone
Guest
 
Posts: n/a
Default

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.
Reply With Quote
  #3  
Old 10-07-2003, 20:24
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: Getting a list of all colors in a Document

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
Reply With Quote
  #4  
Old 15-11-2008, 04:22
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

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?
Reply With Quote
  #5  
Old 15-11-2008, 04:38
Manuel
Guest
 
Posts: n/a
Default

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
Reply With Quote
  #6  
Old 15-11-2008, 05:14
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

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
with the default CMYK and RGB palettes open it would return 5 and 5 as the PaletteID. However in the help for fixed Palettes there is no 5 (and no 4 or 6 either - it just skips from 3 to 7). But if we try to load Palette with ID number 5
Code:
Set pal = Palettes.OpenFixed(5)
it doesn't work, gives an error.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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


All times are GMT -5. The time now is 11:09.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com