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 19-05-2005, 10:33
tonywong
Guest
 
Posts: n/a
Default Photopaint VBA from 12 to 9

i am very happy with the assistance in the web site.

finally i can have this script to faciliate my daily work in Photopaint 12.

However, this script will be run at 2 computers. due to some technical arrangement, one of the computers is a window 98 machine. i am afraid photopaint 12 is not fit for installation on 98 (system requirement is window 2000, i will try if it fits for 98 machine).

i have another solution by changing some codes to fit into Photopaint Version 9. i installed Photopaint 9 w/ VBA support. But i am very frustrated with its object mode cos i cannot find out how to open a file at the 1st stage by the following line or similar object model.

not work ---- Application.OpenDocument (sourcefolder & "\" & strFile)



********** version 12 code ***************
Sub crop()

Dim strFile As String, newFile As String
Dim sourcefolder As String, destinfolder As String
Dim mydate As Date
Dim mydate1 As String
Dim fso

sourcefolder = "C:\temp"
destinfolder = "c:\folder"
strFile = Dir(sourcefolder & "\*.JPG")
mydate = FormatDateTime(Date, vbGeneralDate)
mydate1 = Replace(mydate, "/", "")
Set fso = CreateObject("scripting.filesystemobject")

Do While strFile <> ""
Application.OpenDocument (sourcefolder & "\" & strFile)
ActiveDocument.crop 190, 80, 270, 330
ActiveWindow.WindowState = cdrWindowMaximized
newFile = InputBox("please input the number" & vbLf & vbLf & vbLf & strFile)
If FileExists(destinfolder & "\s" & newFile & ".jpg") Then
MsgBox newFile & " exists! The old file will be marked with a postfix date"
Set f1 = fso.getfile(destinfolder & "\s" & newFile & ".jpg")
f1.Move (destinfolder & "\s" & newFile & "-" & mydate1 & ".jpg")
End If
ActiveDocument.SaveAs(destinfolder & "\s" & newFile & ".jpg", cdrJPEG).Finish
ActiveWindow.Close
strFile = Dir()
Loop

End Sub

Function FileExists(strFile As String) As Boolean
On Error Resume Next
Err.Clear
Call GetAttr(strFile)
FileExists = (Err.Number = 0)
End Function
Reply With Quote
  #2  
Old 19-05-2005, 13:01
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Well, PP9's object model was largely redesigned for PhotoPaint 10. It used to be pretty inflexible and resembled CorelScript commands, rather than a true hierarchical object model.

In PP10 this was changed and the object model was recreated from the ground up. As a result, PP10+ macros are pretty much incompatible with that of PP9. Even something as simple as OpenDocument command in PP9 was called OpenDoc...

I tried to create a sample macro in PP9 which would open a file, crop it and saves under another file but for whatever reason SaveAs method keeps saving the document to the same file and disregards the file name I'm specifying. So here is solution #1 I came up with - just rename the original file before saving:

Code:
Sub Test()
    Dim doc As Document
    Set doc = Application.OpenDoc("C:\Temp\Test.cpt", 0, 0, 0, 0, 0, 1, 1)
    doc.ImageCrop 190, 80, 270, 330
    Name "C:\Temp\Test.cpt" As "C:\Temp\Test_old.cpt"
    doc.Save
    doc.Close
End Sub
Or you can use old CorelScript command to save the file:

Code:
Sub Test2()
    Dim doc As Document
    Set doc = Application.OpenDoc("C:\Temp\Test.cpt", 0, 0, 0, 0, 0, 1, 1)
    doc.ImageCrop 190, 80, 270, 330
    CorelScript.FileSave "C:\Temp\Out.cpt", 1808, 0
    doc.Close
End Sub
Reply With Quote
  #3  
Old 20-05-2005, 11:22
tonywong
Guest
 
Posts: n/a
Default

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
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
"modellation" VBA methods s_federici CorelDRAW/Corel DESIGNER VBA 6 10-07-2003 12:11
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 04:52.


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