OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   Corel Photo-Paint VBA (http://forum.oberonplace.com/forumdisplay.php?f=17)
-   -   Open - Resize - Savefile in Photo Paint (http://forum.oberonplace.com/showthread.php?t=178)

greenee 27-06-2003 08:14

Open - Resize - Savefile in Photo Paint
Hi everyone
Thanks very much for all your help, so far, via this site, the forum and other forums too.

I am trying to save a JPG file from a VBA script, but when it gets to the save part, I always get the compression/filter dialog box, therefore I can't let the computer get on with the job (converting about 3000 photos to a smaller size and then saving) without having to be by the computer to push the OK button. Is there any way you can help me with this problem.

I have scoured the CDRVBA group but can't seem to find this, apart form unanswered similar questions. I also looked at the script for the file converter but can't seem to work out the last part, if file type = 744 then etc etc......I know the 744 is the JPG file type reference but in my code it doesn't like the .filesave. 744,0 part when I put it in.

I guess that maybe something that would return a YES or OK when the dialog box appears would do the trick, but I don't know what the dialog box is called.

If you could help I would greatly appreciate it.
Many thanks
Sub Resample_Longest_side_600pixel()
Dim w As Long, h As Long
Dim vw As Long, vh As Long
vw = 600 ' Desired width
vh = 600 ' Desired height
w = ActiveDocument.SizeWidth
h = ActiveDocument.SizeHeight
If w * vh \ h * vw Then
h = h * vw \ w
w = vw
w = w * vh \ h
h = vh
End If
ActiveDocument.Resample w, h, True
End Sub
Sub File_open_change_size_save_close()

Dim File As String 'declare string needed for storing the filename of each JPG doc
Dim Folder As String 'declare string for the folder where the JPG files are found
Dim Doc As Document 'declare a document variable for any JPG docs that are opened

Folder = "G:\Photo's\Convert_Photos\" 'set folder to location of where your JPG files are
File = Dir(Folder & "*.JPG") 'the "Dir" command will take the the first file from the folder that
'you pass to it. Here we use a wildcard to pickout any .JPG
'documents. The File string will now equal the first JPG
'file that was found

If File <> "" Then 'only proceed if a JPG file has been found
Set Doc = OpenDocument(Folder & File) 'open the JPG file returned by Dir command
'you must include the folder like this too because
'Dir doesn't return the full path to the file
With Doc 'With the file we just opened, do the following...from here you
Resample_Longest_side_600pixel 'Run the macro "Resample_Longest_side_600pixel" (above)
.Close 'close the file
End With

File = Dir 'now the important bit! we say File=Dir in order to point
'to the next JPG file in the folder
Loop Until File = "" 'loop back and perform the same tasks on this new file and
'stop looping as soon as no more files are Left
End If

End Sub

wbochar 27-06-2003 18:20

Read the other Articles; it may help you...

Originally Posted by Alex

Document.SaveAs function in PP11 returns a filter object which needs to be used to finish the save operation:

Dim flt As Object
Set flt = doc.SaveAs(varLargeFile, cdrJPEG)

Or just simply:

doc.SaveAs(varLargeFile, cdrJPEG).Finish

For more information on how to use the filter object returned, please refer to the following article (which was written for Draw 10, but also applies to Draw 11 and Paint 11): http://www.oberonplace.com/vba/exportex.htm

I hope it helps.

The link above shows what things you can set for each format.

greenee 28-06-2003 03:54

SaveAs in PP10
Thanks for that, but I should have said that I have PP 10, and it doesn't seem to like the Doc.SaveAs () command. I get a message saying expected function or variable.

I shall keep trying


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

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