>> Winzip command line

G

Guest

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.
 
M

Michael Bauer

Am Tue, 11 Apr 2006 12:50:01 -0700 schrieb Jonathan:

Jonathan, what is about the support for WinZip? Obviously that is not an
Outlook issue at all :)
 
M

Michael Bednarek

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?
 
G

Guest

Hi Michael, you're right this is not an outlook issue. I just thought that
this maybe something that others had experienced and had a solution...

Regards, Jonathan
 
G

Guest

Michael Bednarek said:
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.

Many Thanks
Jonathan
 
M

Michael Bednarek

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"
 
G

Guest

Michael, thanks friend I'll give it a go when I return to work after the
Easter break.

fyi, I have got into the habit of using chr(34) as I get Togan names that
can include several apostraphys and have found the chr(34) bound strings
handles any number of apostraphys. So I just use chr(34) everywhere <grin>

I included the return value and cmd in a 'try everything' approach to get it
working..

--
Many thanks
Jonathan Parminter


Michael Bednarek said:
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"
 
G

Guest

Michael Bednarek said:
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"

Hi Michael, hope that you had a great Easter Break... <smile>

Using your example above I have tried the following

strZipCommandLine = """C:\Program Files\WinZip\WZUNZIP.exe"" -o " _
& "O:\PriceLists_Practice\Test\CDPricing.zip
O:\PriceLists_Practice\Test\CDPricing.xls"
'extract zip file
Debug.Print "command line: " & vbNewLine & strZipCommandLine
Shell strZipCommandLine, vbHide

Unfortunitely, without success.

Any further ideas or suggestions :)

Many thanks
Jonathan
 
M

Michael Bednarek

Michael Bednarek said:
:

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 ***** [snip]
*****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"

Hi Michael, hope that you had a great Easter Break... <smile>

Using your example above I have tried the following

strZipCommandLine = """C:\Program Files\WinZip\WZUNZIP.exe"" -o " _
& "O:\PriceLists_Practice\Test\CDPricing.zip
O:\PriceLists_Practice\Test\CDPricing.xls"
'extract zip file
Debug.Print "command line: " & vbNewLine & strZipCommandLine
Shell strZipCommandLine, vbHide

Unfortunitely, without success.

Any further ideas or suggestions :)

Read the documentation for WzUnzip; construct a command line that
works from a command line window (e.g. CMD); transport that working
command line into your VBA code.

I believe your version still doesn't use WzUnzip's last and
second-to-last parameters properly. From WzUnzip's Help:

wzunzip [options] zipfile [@listfile] [[drive:][\][path][\]] [files...]

As I wrote before:
Note that files are unqualified names; the target directory is an
optional parameter just before files.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top