LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default how do i open a zip file using a macro


Ron..

the Wait solution...Counting!

I also noted that the NameSpace method
fails if you pass it a string variable....


Sub Zip_All_Files_in_Folder()

Dim sDefPath$, sDate$
Dim vZipPath, vFldPath 'MUST be Variants!
Dim lFldCount&
Dim oApp As Object
Dim oZip As Object
Dim oFld As Object

vFldPath = "e:\testje\" '<< Change

sDefPath = Application.DefaultFilePath
sDefPath = "e:\"

If Right(sDefPath, 1) < "\" Then
sDefPath = sDefPath & "\"
End If

sDate = Format(Now, " dd-mmm-yy h-mm-ss")
vZipPath = sDefPath & "MyFilesZip " & sDate & ".zip"

'Create empty Zip File
Call NewZip(vZipPath)

Set oApp = CreateObject("Shell.Application")
Set oFld = oApp.Namespace(vFldPath)
Set oZip = oApp.Namespace(vZipPath)

'Get the count of files to be compressed
lFldCount = oFld.Items.Count

'Copy the files to the compressed folder
oZip.CopyHere oFld.Items

'Keep script waiting until Compressing is done
Do Until oZip.Items.Count = lFldCount
Application.Wait (Now + TimeValue("0:00:01"))
Loop


MsgBox "You find the zipfile he" & vbLf & vZipPath
Set oFld = Nothing
Set oZip = Nothing
Set oApp = Nothing
End Sub



--






--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Ron de Bruin wrote :

Hi keepITcool

You code example is working Ok and is shorter and simpler .

BTW : do you have better idea about the wait code on my site
http://www.rondebruin.nl/windowsxpzip.htm#Wait

I test a few other things but this is the only thing that is working
for me (also with big Excel files 5-10 mb)



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Excel file from VB and open MACRO no1jimmyman Excel Discussion (Misc queries) 0 February 14th 11 10:10 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Macro to call a file that has a auto open macro in the file itself [email protected] Excel Programming 1 August 5th 05 06:39 AM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"