Zip Function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob

    Zip Function

    Hello,
    I am trying to zip a folder(this folder contains several
    files), from access application.Thi s is as a part of back up
    procedures which I am writing.I have written the timer program for
    other functions .I wrote a code to utilize the WinZip exe.While it
    zips the folder ,the folder does not exist after the zip procedure.I
    want some help in tuning this code so that the original folder is
    still retained in addition to the zipped one.Also ,I need to place a
    copy of this zipped folder to another drive.Any help greatly
    appreciated.

    Thanks,

    Rob
  • Tony Toews

    #2
    Re: Zip Function

    chenboyus@yahoo .com (Rob) wrote:
    [color=blue]
    > I am trying to zip a folder(this folder contains several
    >files), from access application.Thi s is as a part of back up
    >procedures which I am writing.I have written the timer program for
    >other functions .I wrote a code to utilize the WinZip exe.While it
    >zips the folder ,the folder does not exist after the zip procedure.I
    >want some help in tuning this code so that the original folder is
    >still retained in addition to the zipped one.Also ,I need to place a
    >copy of this zipped folder to another drive.Any help greatly
    >appreciated.[/color]

    FWIW there are free alternatives which are open sourced and thus don't require
    individual licenses. See Compression DLLs, OCXs, etc


    Tony
    --
    Tony Toews, Microsoft Access MVP
    Please respond only in the newsgroups so that others can
    read the entire thread of messages.
    Microsoft Access Links, Hints, Tips & Accounting Systems at

    Comment

    • Tony Toews

      #3
      Re: Zip Function

      chenboyus@yahoo .com (Rob) wrote:
      [color=blue]
      >Also ,I need to place a
      >copy of this zipped folder to another drive.Any help greatly
      >appreciated.[/color]

      See the Name statement. Hmm, different drive. See the FileCopy Statement.

      Tony
      --
      Tony Toews, Microsoft Access MVP
      Please respond only in the newsgroups so that others can
      read the entire thread of messages.
      Microsoft Access Links, Hints, Tips & Accounting Systems at

      Comment

      • David B

        #4
        Re: Zip Function

        Try putting this in a module.
        You will need to set Source Path, Source File and Backup Path to suit your own
        set up
        HTH
        David B


        Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

        Public Function BackupAndZipitt oC()

        'This function will allow you to copy a db that is open,
        'rename the copied db and zip it up to anther folder.

        'You must set a reference to the 'Microsoft Scripting Runtime' for the CopyFile
        piece to work!

        'Thanks to Ricky Hicks for the .CopyFile code also G Hudson

        Dim fso As FileSystemObjec t

        Dim sSourcePath As String
        Dim sSourceFile As String
        Dim sBackupPath As String
        Dim sBackupFile As String

        sSourcePath = "C:\Hoofpri nt\"
        sSourceFile ="Stock_be.m db"
        sBackupPath = "C:\Hoofprint\B ackups"
        sBackupFile = "Backupstoc k_" & Format(Date, "mmddyyyy") & "_" & Format(Time,
        "hhmmss") & ".mdb"

        Set fso = New FileSystemObjec t
        fso.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True
        Set fso = Nothing

        Dim sWinZip As String
        Dim sZipFile As String
        Dim sZipFileName As String
        Dim sFileToZip As String

        sWinZip = "C:\Program Files\WinZip\Wi nZip32.exe" 'Location of the WinZip program
        sZipFileName = Left(sBackupFil e, InStr(1, sBackupFile, ".", vbTextCompare) - 1)
        & ".zip"
        sZipFile = sBackupPath & sZipFileName
        sFileToZip = sBackupPath & sBackupFile

        Call Shell(sWinZip & " -a " & sZipFile & " " & sFileToZip, vbNormalFocus)
        MsgBox "Backup is proceeding. This routine can take up to 10 seconds to
        complete"
        Sleep 10000

        If Dir(sBackupPath & sBackupFile) <> "" Then Kill (sBackupPath & sBackupFile)
        Beep
        MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & sBackupPath &
        Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) &
        sZipFileName, vbInformation, "Backup Completed"



        End Function

        Rob <chenboyus@yaho o.com> wrote in message
        news:6008fdef.0 402131807.44006 d50@posting.goo gle.com...[color=blue]
        > Hello,
        > I am trying to zip a folder(this folder contains several
        > files), from access application.Thi s is as a part of back up
        > procedures which I am writing.I have written the timer program for
        > other functions .I wrote a code to utilize the WinZip exe.While it
        > zips the folder ,the folder does not exist after the zip procedure.I
        > want some help in tuning this code so that the original folder is
        > still retained in addition to the zipped one.Also ,I need to place a
        > copy of this zipped folder to another drive.Any help greatly
        > appreciated.
        >
        > Thanks,
        >
        > Rob[/color]

        Comment

        Working...