Resize with VBA - RealWorld forums

Log-in or register.

Resize with VBA

Shell command
PeterJZ
on April 25th 2008

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.

Vlasta
on April 25th 2008

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

PeterJZ
on April 26th 2008

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

PeterJZ
on May 3rd 2008

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?

Vlasta
on May 3rd 2008

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.

PeterJZ
on May 16th 2008

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!!

Page views: 2929       Posts: 6      
Vista & Win 7 icons
Select background
I wish there were...