OK... It's me again. Same project. I'm trying to loop through files in a directory and set the page size on all the PDFs. I'm having difficulty getting the file names in the parameters I need to pass them through ghostscript. I gave up on changing the parameters IN the .run shell command and decided to create the parameters in a variable (as you can see). My problem seems to be in the strParam variable that I am passing. It looks correct when I check it in the msgbox but when the script runs I don't get any files created. If I hardcode the 2 parameters I need to change ("-sOUTPUTFILE=" and file name) it works as expected.
Dim FSO, FLD, FIL, X
Dim strInput, strFolder, strParam
strInput = InputBox ("1 - Landscape" & chr(13) & "2 - Portrait", "Original Image Orientation")
strFolder = InputBox ("Copy and paste the folder location" & chr(13) & "to your scans", "File Location")
Set objShell = WScript.CreateObject("WScript.Shell")
If strInput=1 then
Call LandScape
ElseIf strInput=2 Then
Call Portrait
Else
MsgBox "Your entry is invalid. Click OK to exit"
End If
Sub LandScape
ObjShell.CurrentDirectory= strFolder
Wscript.Echo objShell.CurrentDirectory
MsgBox "Your images are Landscape"
MsgBox "Your files are located at: " & strFolder
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FLD = FSO.GetFolder(strFolder)
For Each FIL In FLD.Files
strParam = chr(34) & " -dQUIET -dNOPAUSE dBATCH -dDEVICEWIDTHPOINTS=2592 -dDEVICEHEIGHTPOINTS=1728 -dFIXEDMEDIA -sDEVICE=pdfwrite -sOutputFile=new-" & FIL.Name & " " & FIL.Name & chr(34) & chr(34) & chr(34)
MsgBox strParam
objShell.Run """c:\Program Files\gs\gs9.04\bin\gswin64c.exe" & strParam
Next
End Sub