View Single Post
  #5  
Old April 13th 06, 02:31 AM posted to microsoft.public.outlook.program_vba
Jonathan
external usenet poster
 
Posts: 49
Default Winzip command line



"Michael Bednarek" wrote:

On Tue, 11 Apr 2006 12:50:01 -0700, Jonathan wrote in
microsoft.public.outlook.program_vba:

Hi, I have a procedure that finds a folder and then for each mail item with
an attachment saves the attachment. For attachments that are zip files I then
unpack them. Well attempt to...

I have downloaded winupzip.exe for this purpose and use the line:

intRet = shell("path\winupzip -o path\file.zip path\fileSaveName", vbHide)

When stepping through the code in debug mode this line does not cause any
errors. Yet does not have the desired result.

intRet does return a non-zero value. However, I don't know where to find the
description for this value.


There is no such program (winupzip).

What exactly did you put into Shell()? Not what you showed in your post,
I presume. Note that path names should be unambigous, i.e. they should
be complete. E.g.: d:\dir\file.ext, not dir\file.

What happens when you run the Shell() with vbNormalFocus? What happens
when you run that command from a CLI?

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"


Hi Michael, runnig shell with vbnormalfocus does not improve things.
The code I'm using is:

****** code start *****
strFileDestination = "C:\Solution\ZipTest.doc" 'cPriceListPath &
GetSupplierValue("saved as")
If Dir(strFileDestination, vbNormal) "" Then
'Rename as _backup
intLen = Len(strFileDestination) - 3
strFileDestinationBkUp = Left(strFileDestination, intLen - 1) & _
"_backup" & Mid(strFileDestination, intLen)
Name strFileDestination As strFileDestinationBkUp
End If
'Check whether attachment is a zip file
If Right(.FileName, 3) = "zip" Then
' strZipFile = cPriceListPath & .FileName
strZipFile = "C:\Solution\" & .FileName
'Check whether an existing zip file at this location
If Dir(strZipFile, vbNormal) "" Then
'remove file
Kill strZipFile
End If
'save to destination location and name
.SaveAsFile (strZipFile)
'Create zip exe command line to extract file to destination
location and name
strZipCommandLine = Chr(34) & cWinupZip & Chr(34) & Space(1) & _
Chr(34) & strZipFile & Chr(34) & Space(1) & _
Chr(34) & strFileDestination & Chr(34)
'extract zip file
If Not Shell(strZipCommandLine, vbHide) Then
MsgBox "Unzip error"
End If
'otherwise, save attachment to destination location and name
Else
.SaveAsFile (strFileDestination)
End If
*****code end *****
Using the debug window the variable strZipCommandLine contains...
"c:\windows\system32\cmd.exe" "C:\Program Files\WinZip\wzunzip.exe"
"C:\Solution\Mail Merge - many items for each record.zip"
"C:\Solution\ZipTest.doc"

If the attachment is not a zip file then the process works.
The command line follows the syntax given in the winzip help file.

Many Thanks
Jonathan
Ads