user iconPeterJZ on April 24th 2008
3021 views

topic iconResize with VBA

Shell command

Thanks very much for your previous help.

I am back with a further question. The code provided on my previous question works perfectly on the command line (Run command), but I want to go one step further and use it in VBA (Access 2007). I currently have the following line in the code, but it does not work.

RetVal = Shell("PhotoResize400.exe - n - q100 - o & """ & strDest & """ & """ & strFileName & """", vbHide)

WHERE strDest is the full path to the destination with "-c" added in front

AND strFileName the full path and filename of the file to be resized.

I know this is asking a lot, but could you help with this as well?

Thanks a million.

user iconVlasta on April 24th 2008 0

My guess would be:
RetVal = Shell("PhotoResize400.exe -n -q100 -o """ & strDest & """ """ & strFileName & """", vbHide)

user iconPeterJZ on April 25th 2008 0

Thanks once again Vlasta, it works perfectly now!! You are one talented man!

user iconPeterJZ on May 2nd 2008 0

With relation to my previous post:

I have just noticed that the resizing does not place when the filepath in strDest is the same as the path in strFileName. The command you suggested works well for renaming a file and placing it in another directory, as long as they are not the same. I know how to simply rename a file without placing a copy of it in another directory, but then PhotoResize adds "-400" to the end of the fielname, which I do not want.

Ideally, I would want to use only one command, and it should not matter whether the source and destination are the same, but I don't know if this is possible.

Could you please help me solve this?

user iconVlasta on May 2nd 2008 0

Overwriting the original file directly is dangerous. If an error occurs during writing the file, it is lost forever. When Picture Resizer is set to do in-place conversion, it still saves the resized image to a different file, then (if it succeeds) it deletes the original and finally changes the name of the resized file to the original one.

I would suggest to use the capabilities built in Picture Resizer to do safe in-place conversion -> leave out the -c switch and use the -i switch.

user iconPeterJZ on May 15th 2008 0

Sorry for answering only now - I've been out of town for the last few weeks. I will try the -i switch.

Thanks once again!!

user icon