View Single Post
  #4  
Old 20-04-2010, 01: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 CorelDRAW to PP

Hopefully this will get you started, it is far from perfect, no error handlers so things could go wrong. :-)

First you need to add a reference to PHOTO-PAINT in CorelDRAW. Do this by opening the VBA editor (ALT-F11) clicking Tools | References | And check the Corel - Corel PHOTO-PAINT Type Library, then click ok.

Second make sure you have a folder named c:\temp or change this in the code to a folder the already exists.

Now you should be able to use the code.
Code:
Sub FromDrawToPhotoPaintAndBackAgain()
    Dim appDraw As New CorelDRAW.Application
    Dim appPaint As New PHOTOPAINT.Application
    Dim filter As CorelDRAW.ExportFilter
    Dim docPP As PHOTOPAINT.Document
    Dim docDRAW As CorelDRAW.Document
    Dim sOrigBitmap As CorelDRAW.Shape, sNewBitmap As CorelDRAW.Shape
    Dim x As Double, y As Double
    
    If appDraw.ActiveShape.Type = cdrBitmapShape Then
        Set sOrigBitmap = appDraw.ActiveShape
        Set docDRAW = appDraw.ActiveDocument
        sOrigBitmap.GetPosition x, y
        Set filter = docDRAW.ExportBitmap("C:\temp\~temp.jpg", cdrJPEG, cdrSelection, cdrRGBColorImage)
        filter.Finish
        Set filter = Nothing
        
        Set docPP = appPaint.OpenDocument("c:\temp\~temp.jpg")
        appPaint.CorelScript.BitmapEffect "Channel Mixer", Chr(7) + "ChannelMixerEffect InputColourModel+AD0-1,OutputChannel+AD0-0,PreviewOutputOnly+AD0-0,Level1+AD0-160+AHw-0+AHw-0+AHw-0,Level2+AD0--140+AHw-100+AHw-0+AHw-0,Level3+AD0-160+AHw-0+AHw-100+AHw-0,Level4+AD0-0+AHw-0+AHw-0+AHw-100"
        docPP.SaveAs("c:\temp\~temp.jpg", cdrJPEG).Finish
        docDRAW.ActiveLayer.Import "c:\temp\~temp.jpg"
        Set sNewBitmap = appDraw.ActiveSelection
        sNewBitmap.SetPosition x, y
        sOrigBitmap.Delete
        Kill "c:\temp\~temp.jpg"
    End If
End Sub
The code simply exports the currently selected bitmap, adds a Channel Effect in PHOTO-PAINT then sends it back to CorelDRAW deleting the original.

-Shelby
Reply With Quote