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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zip Multiple MDB's Into 1 Zip

Status
Not open for further replies.

Fattire

Technical User
Nov 30, 2006
127
US
Using WinZip I can zip one file with the following code, but I'm having problems getting more then one file into this winzip file.

Code:
Private Sub Form_Load()

    Dim ZipPath As String
    Dim ZipFile As String
    Dim ZipApp As Shell
    Dim strpath As String
    Dim today As String
    Dim fol as String
    
    today = Format(Now(), "DD-MMM-YYYY")
    
    Set ZipApp = New Shell
    
    fol = "Z:\Production Database Backups"
    strpath = "Z:\Production Database Backups\*.mdb"
    ZipPath = fol & "\" & today & ".zip"

    CreateEmptyZip ZipPath
    
    With ZipApp
        .Namespace(ZipPath).CopyHere (strpath)
    End With

End Sub

Public Sub CreateEmptyZip(sPath)

    Dim strZipHeader As String

    strZipHeader = Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
    With CreateObject("Scripting.FileSystemObject")
        .CreateTextFile(sPath).Write strZipHeader
    End With

End Sub


Any help would be appreciated.
 
You want to create a new ZIP file only if it doesn't already exist.
Code:
    [COLOR=black cyan]' Create a new ZIP file if it doesn't exist[/color]
    If Dir(ZipPath) = "" Then CreateEmptyZip ZipPath

You can also copy all the files in a directory into a zip file with
Code:
.NameSpace(sPath).CopyHere.NameSpace ("Z:\Production Database Backups\").Items
 
thanks for the reply!

I'm getting a "Argument not optional" on the copyhere

I've tried a few vOptions too, none of those were working
 
Sorry ... missed a space
Code:
.NameSpace(sPath).CopyHere .NameSpace("Z:\Production Database Backups\").Items
 

Wow that's crazy, a spacebar? palleeeze... but now it makes sense with it separated like that - I've learned a lot, thanks for your help Golom.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top