ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to open a zip file and extract its contents in a macro? (https://www.excelbanter.com/excel-programming/278429-how-open-zip-file-extract-its-contents-macro.html)

Audie G. Bencosme R.

How to open a zip file and extract its contents in a macro?
 
Hi
I need to save space in my hard disk so i have to zip some files, but i need
them for consulting values and make some reports, i need to run a macro that
opens the zip file, extract the workbook copy some values from it and then
close it without making changes, and close the zip file.
The zip file and the workbook have the same name.
This operation is done by hand 5 times everyday so you'll understand my
need.
Please any help is needed



Dave Peterson[_3_]

How to open a zip file and extract its contents in a macro?
 
Hard drive space is pretty cheap nowadays. It might be easier just investing a
few bucks into a larger HD.

But there are command line versions of the unzipping programs. (I think PKZip
(www.pkzip.com) has a version.)

You could use a shellandwait routine to unzip the file.
http://support.microsoft.com/?kbid=214248
XL2000: How to Force Macro Code to Wait for Outside Procedure

Here's a link to a nice ShellAndWait function that does that.
http://groups.google.com/groups?thre...%40tkmsftngp03

Then open that workbook, copy the data you want, close without saving and kill
the file.

dim wkbk as workbook
set wkbk = workbooks.open(filename:=whateveryouextracteditto)
wkbk.worksheets("sheet1").range("b1:C99").copy _
destination:= thisworkbook.worksheets("sheet99").range("x7")
wkbk.close savechanges:=false
kill whateveryouextracteditto


might give you an idea.



"Audie G. Bencosme R." wrote:

Hi
I need to save space in my hard disk so i have to zip some files, but i need
them for consulting values and make some reports, i need to run a macro that
opens the zip file, extract the workbook copy some values from it and then
close it without making changes, and close the zip file.
The zip file and the workbook have the same name.
This operation is done by hand 5 times everyday so you'll understand my
need.
Please any help is needed


--

Dave Peterson



All times are GMT +1. The time now is 03:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com