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

how to zip/unzip files from within Access

Status
Not open for further replies.

pdtit

Technical User
Nov 4, 2001
206
0
0
BE
Hi,

In my application I use some macro's (still have to convert them to VBA) to export tables to another mdb-file.

THis mdb-file should be transferred using a 56k dial-up line. The transfer itself is done using PCAnywhere.

TO speed up things a bit, I'd like to zip my mdb-file before transfert.

On the other side, I want to unzip the file before importing tables from the new mdb.

DOes anyone know how to do this?

Regards,

Peter
 
You would need to use a zip utility that can be executed from the command line like winzip or one of MANY freeware zip utilities. Then you simply use the shell command from within your module to unzip your app.

Hope this helps.


Burglar
 
This might be some use:
Zip files from VBA using windows inbuilt compressing software
thread181-1130420
 
Or this:
Create ZIP file code
thread707-1091905
 
Guys, I can't remember where On-Line, I got this but, very effective....

Code:
Option Compare Database
Option Explicit

Declare Function OpenProcess Lib "kernel32" _
        (ByVal dwDesiredAccess As Long, _
        ByVal bInheritHandle As Long, _
        ByVal dwProcessId As Long) As Long
 
Declare Function GetExitCodeProcess Lib "kernel32" _
        (ByVal hProcess As Long, _
        lpExitCode As Long) As Long
 
Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103

_________________________________________________________________

Public Sub ShellAndWait(ByVal PathName As String, Optional WindowState)

On Error GoTo xxx

    Dim hProg As Long
    Dim hProcess As Long, ExitCode As Long
    'fill in the missing parameter and execute the program
    If IsMissing(WindowState) Then WindowState = 1
    hProg = Shell(PathName, WindowState)
    'hProg is a "process ID under Win32. To get the process handle:
    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProg)
    Do
        'populate Exitcode variable
        GetExitCodeProcess hProcess, ExitCode
        DoEvents
    Loop While ExitCode = STILL_ACTIVE

Exit Sub
xxx:
MsgBox "Unexpected error - " & err.Number & vbCrLf & _
vbCrLf & Error$, vbExclamation, "Modules - SheAndWai"
Exit Sub

End Sub

_____________________________________________________________


Sub ZipFile()

On Error GoTo xxx

    Dim PathWinZip As String, sFileNameZip As String, strFolder As String
    Dim ShellStr As String, sFileNameMdb As String
 
    PathWinZip = "C:\Program Files\WinZip\"
        
        strFolder = "C:\Documents and Settings\Dan\My Documents\BackUp\DBase\FSX"
        sFileNameMdb = strFolder & "\FSX.mdb"
        sFileNameZip = strFolder & "\FSXII.zip"
                 
        ShellStr = PathWinZip & "Winzip32 -min -a" _
                 & " " & Chr(34) & sFileNameZip & Chr(34) _
                 & " " & Chr(34) & sFileNameMdb & Chr(34)

        Call ShellAndWait(ShellStr, vbHide)
        'Call EmailAttachment(strFolder & "\FSXBE.zip")
        
        Kill (strFolder & "\FSXBE.zip")

Exit Sub
xxx:
MsgBox "Unexpected error - " & err.Number & vbCrLf & _
vbCrLf & Error$, vbExclamation, "Modules - ZipFile"
Exit Sub

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top