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 09-11-2006, 08:58
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default Custom Palettes via VBA

In the following code, I am trying to open userinks.cpl to apply custom color "CutPath" to the outline of the selected object. At the Palettes.OpenFixed(cdrUserInks) I get an error "invalid procedure call or argument". What am I doing wrong?
Code:
Sub ApplyCutPath()
    Dim os As Shape
    Dim CSPalette As Palette
    Dim CSColor As Color
    
    Set os = ActiveSelection

    For Each CSPalette In Palettes
        If CSPalette.Type = cdrFixedPalette Then
            If CSPalette.PaletteID = cdrUserInks Then
                Exit For
            End If
        End If
    Next CSPalette
    
    If CSPalette Is Nothing Then
        Set CSPalette = Palettes.OpenFixed(cdrUserInks) 'trying to open userinks.cpl
    End If
    
    'Apply color named CutPath to outline of selected object
End Sub
BTW, Alex, I like the new spell check feature. This is too cool.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 09-11-2006, 09:25
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

O.K. I figured out how to open it...
Code:
Palettes.Open "C:\Documents and Settings\Artist\Application Data\Corel\Graphics13\User Custom Data\Palettes\userinks.cpl"
Now, how do I close it after doing my "other stuff"?
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #3  
Old 09-11-2006, 10:59
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default OpenClose

Try this:
Code:
Sub OpenClosePaletes()

Dim pal As Palette
Dim palUserInks As Palette

Set palUserInks = Palettes.Open("C:\Documents and Settings\Shelby\Application Data\Corel\Graphics13\User Custom Data\Palettes\userinks.cpl")

For Each pal In Palettes
    If pal.Name <> "Default CMYK palette" Then pal.Close
Next pal

End Sub
Best of luck,

Shelby
Reply With Quote
  #4  
Old 10-11-2006, 08:28
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Well, you can use the palette object returned by Palettes.Open method to call the Close method on.

Also, instead of specifying the full path the the palette, you can use Application.UserDataPath to return the path to the user's custom data folder:

Code:
Sub UserInksPalette()
    Dim pal As Palette
    Dim s As Shape
    
    ' Open the palette
    Set pal = Palettes.Open(Application.UserDataPath & "Palettes\userinks.cpl")
    
    ' Do your stuff with the colors in this palette
    Set s = ActiveLayer.CreateRectangle(0, 0, 2, 2)
    s.Fill.ApplyUniformFill pal.Color(2)
    
    ' Now close the palette
    pal.Close
End Sub
Correction: this is how it's supposed to work but somehow the pal.Close statement fails. Apparently there is some problem with it. Will have to investigate further....
Reply With Quote
  #5  
Old 10-11-2006, 09:07
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Ok, it appears there is a bug in the palette code somewhere. However there is a workaround. You must ensure that the instance of Palettes collection stays alive while you work with your userinks palette. This seems to have worked. Here is the revised code:

Code:
Sub UserInksPalette()
    Dim pal As Palette
    Dim pals As Palettes
    Dim s As Shape
    
    Set pals = Palettes ' Keep the reference to Palettes until we are done working with the current palette
    
    ' Open the palette
    Set pal = pals.Open(Application.UserDataPath & "Palettes\userinks.cpl")
    
    ' Do your stuff with the colors in this palette
    Set s = ActiveLayer.CreateRectangle(0, 0, 2, 2)
    s.Fill.ApplyUniformFill pal.Color(2)
    
    ' Now close the palette
    pal.Close
End Sub
Reply With Quote
  #6  
Old 10-11-2006, 12:05
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default pal.close

Hey at least I wasn't the only one that tried the pal.close first. Got the same result that it would fail. Very nice workaround Alex, that is why you are the best!

Shelby
Reply With Quote
  #7  
Old 11-11-2006, 15:19
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Spell Check

BTW Sean I don't think the spell check is on the forum. I would bet money you are using Firefox 2 and it is built into it. Fun Fun and yes way cool.

Shelby
Reply With Quote
  #8  
Old 13-11-2006, 07:53
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

ding, ding, ding... You are correct. I thought it was something that Alex put on the site (since I asked many moons ago). Did not realize this was a feature of FF2.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
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
Where to begin with CorelDRAW and VBA shelbym CorelDRAW/Corel DESIGNER VBA 2 03-04-2007 09:15
delete vba project from cdr file hotairballoon CorelDRAW/Corel DESIGNER VBA 1 18-05-2005 09:08
CD 10, VBA not returning true outline width Webster CorelDRAW/Corel DESIGNER VBA 1 24-11-2004 17:09
VBA does not work with my CD 10 ! jobar CorelDRAW/Corel DESIGNER VBA 1 24-08-2003 12:38
Detect if VBA is installed (an answer and a question) reanan CorelDRAW/Corel DESIGNER VBA 3 04-12-2002 14:35


All times are GMT -5. The time now is 00:31.


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