Winzip using VBA - add file to zip subfolder

TomPC

Board Regular
Joined
Oct 13, 2011
Messages
95
Hi all

This is really a DOS/Command Line/Shell question but it's being run out of VBA and I know this forum better than any other.

I need to add a file to a zip file. I have working code that does this using SHELL() the below:

Code:
"C:\Program Files\Winzip\winzip32" -min -a "C:\tmp\testfile.zip" "C:\style\styles.xml"

The problem is I need to add the file 'styles.xml' to a folder in 'testfile.zip' called 'xl'. The above code only adds it to the root of testfile.zip.

Anyone know how to amend my command line script?

Thanks

Tom
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hello TomPC,

You need to include the -p and/or the -r options. The former option will list the complete path while the latter option will display only the file and any subfolders in the folder where the file is located.

Remember any file names with spaces must include the beginning and ending quotes.
Filename = "C:\MyFile.zip"
Filename = """C:\My File.zip"""
Code:
Shell "C:\Program Files\WinZip\WinZip32.exe -min -a -p " & ZipFile & " " & Filename
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,918
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top