Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zip an Excel File

Status
Not open for further replies.

mveera

Programmer
Nov 6, 2002
81
US
Hi,

I would like to know if there is any in-built API in Excel/Access to zip a file.

Currently i use the Shell API to open a Winzip session and zip the file. This requires manual intervention. I would like to know if it is possible zip the file programatically.

Thanks
Veera
 
Hi,

How, where and when would you like to do this programmatically? (You are already using API).

i.e. If no user interaction is wanted - when is the action required?

Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 

Yes there is. If you search the web you will eventually find a web site that contains dll's that you can call to make and break zips. Also along the way you will probably run across the code to do the same with cab files. Search yahoo or google.

Good Luck

 
Hi there is a command line add-on for WinZip available at
Double click the downloaded file wzcline.exe, install to your current WinZip directory. After installation is complete, copy the files WZZIP.EXE and WZUNZIP.EXE to your System directory so that WZZIP and WZUNZIP can be called from anywhere without specifying their path.

To use WZZIP follow the example below, put this in the on click event of a button:

Dim Retval, strZipFile As String, strFilesToZip As String
strZipFile = "c:\MyTestFile.zip" ‘zip file to create or add to
strFilesToZip = "c:\My Documents\*.xls" ‘file(s) to add to zip file
Retval = Shell("wzzip " & """" & strZipFile & """" & " " & """" & strFilesToZip & """", 1)

This still “requires some manual intervention”, like selecting the ZipFile to Zip or UnZip but doesn’t require WinZip to be opened.

There is an excellent concise and to the point help file that comes with the download. I’m sure you will find this an invaluable tool.

The quotes in the code are to allow for folder names that have spaces in them. Let me know how you get on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top