OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > Corel Photo-Paint VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-05-2009, 08:18
Manuel
Guest
 
Posts: n/a
Default PhotoPaint crashes everytime I run this macro

I'm trying to write a macro for Photo Paint, but, since there is no recorder and not much documentation, I'm going by trial and error. The problem I'm having is that PP crashes every time I run this macro and try to close the document without saving the changes. Maybe somebody can take a look at it and detect what I'm doing wrong that causes so many crashes.

Code:
Sub IndexSixSimple()

    '-----------------------------------------------------------------------------
    'Index separations with six basic colors in simple form.
    'Macro created by Manuel Rivas. April 2009
    'This macro takes either an RGB or CMYK file and separates it in six primary
    'colors: Black, White, Yellow, Blue, Red and Green
    '-----------------------------------------------------------------------------

    Dim Doc As Document, pal As Palette
    Dim Blk As Color, Wht As Color, Yel As Color, Red As Color, Grn As Color, Blue As Color
    Dim FOpen As String, palpath As String
    Dim cm1 As New ColorMask
    Dim CRed As Channel
    
    Set Doc = ActiveDocument
    
        If Doc Is Nothing Then
        MsgBox "Open File first", vbOKOnly, "There are no open documents"
        FOpen = CorelScriptTools.GetFileBox("Bitmap Files (*.bmp; *.jpg; *.tif; *.cpt; *.psd)|*.bmp; *.jpg; *.tif; *.cpt; *.psd", _
        "Open File")
        End If
        
        If FOpen <> "" Then
        Set Doc = Application.OpenDocument(FOpen)
        Else
            If Doc Is Nothing Then
            Exit Sub
            End If
        End If
    
    Set pal = Palettes.Create("Six Simple", , True)
    palpath = pal.FileName
    
    Set Blk = CreateColorEx(2, 0, 0, 0, 100)
    Set Wht = CreateColorEx(2, 0, 0, 0, 0)
    Set Yel = CreateColorEx(2, 0, 0, 100, 0)
    Set Red = CreateColorEx(2, 0, 100, 100, 0)
    Set Grn = CreateColorEx(2, 100, 0, 100, 0)
    Set Blue = CreateColorEx(2, 100, 28, 0, 0)
    
        With pal
        .AddColor Blk
        .AddColor Wht
        .AddColor Yel
        .AddColor Red
        .AddColor Grn
        .AddColor Blue
        End With
        
    Doc.ConvertToPaletted cdrPaletteCustom, cdrDitherJarvis, 100, , , , , , , , , palpath
        
        With cm1
        .AddColor Red
        .Threshold = 1
        .Inverted = True
        End With
        
    Set CRed = Doc.Channels.AddFromColorMask(cm1, "Red", 100, Red)
    

End Sub

Last edited by Manuel; 11-05-2009 at 08:21.
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
Corel Draw 8 crashes all the time Blind Dog Studios General 6 31-07-2010 18:01
Bug and crashes using connectors vjCorel CorelDRAW/Corel DESIGNER VBA 5 01-05-2009 09:41
Picture Publisher 9 crashes under Windows XP annedeblois General 1 11-02-2009 08:28
Crashes with VBA in Draw X3 clausm CorelDRAW/Corel DESIGNER VBA 5 02-04-2007 15:23
Corel Draw X3 crashes on spell check IMRKE General 1 23-02-2006 07:21


All times are GMT -5. The time now is 21:16.


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