![]() |
#1
|
|||
|
|||
![]()
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 Rob ======================================================================================== 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 Else 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 Do 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) .Save 'Save file FROM HERE IS WHERE I HAVE THE PROBLEM ![]() .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 |
#2
|
|||
|
|||
![]() Quote:
|
#3
|
|||
|
|||
![]()
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 Regards Rob |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Corel Photo Paint 11 Document Events problem | cyrilgupta | Corel Photo-Paint VBA | 1 | 07-11-2004 12:51 |
color profile problem in Photo Paint 9 | flip | Corel Photo-Paint VBA | 2 | 11-07-2003 03:55 |