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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

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