On Wed, 12 Apr 2006 17:31:02 -0700, Jonathan wrote in microsoft.public.outlook.program_vba:
"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?
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.
No it doesn't:
wzunzip [options] zipfile [@listfile] [[drive:][\][path][\]] [files...]
Note that files are unqualified names; the target directory is an
optional parameter just before files.
Also: you don't need to invoke CMD to execute a program (wzunzip), but
if you do, you have to include the /c or /k switch.
There is no need to ofuscate the code with Chr(34) - just use two
quotes where you want to include a quote in the string.
Testing the return value of Shell() as a boolean should never
return False. The Shell function "Runs an executable program and
returns a Variant (Double) representing the program's task ID if
successful, otherwise it returns zero."
strFileDestination = "ZipTest.doc"
strZipCommandLine = """C:\Program Files\WinZip\wzunzip.exe"" -o """ _
& strZipFile & """ C:\Solution " & strFileDestination
The above is not tested, but the one below is:
strCmdLine = """C:\Program Files\WinZip\wzunzip.exe"" -o " _
& "C:\Temp\Default\Test.zip C:\Temp\Default ttt.vbs"
--
Michael Bednarek
http://mbednarek.com/ "POST NO BILLS"