Results 1 to 4 of 4
  1. #1
    joanas is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    9

    Zip files

    Hi,

    I want to zip just 5files from a folder with 30 files.. i have this code:

    but i don't want to do a copy of the files first.. because the files are to big and takes a lot of time..

    I want to access the folder, and zip just the files that i want for another folder. Can you help me?


    '------------------------------------------------------------------------------------------
    'Backup
    Private Sub Comando96_Click()


    month_n = DLookup("month([Fec_data])", _
    "T_MES")


    year_n = DLookup("year([Fec_data])", _
    "T_MES")






    MkDir ("G:\OrcControlo\SCC\Processo\Backups\" & year_n & "\" & year_n & "0" & month_n)






    'compact bd
    Application.SetOption "Auto compact", True

    'secutiry copy
    FileCopy "G:\Orc\S\Process\00", "G:\Orc\S\Process\Backups\Backup\00Custos_tabelas_ gerais.mdb"
    FileCopy "G:\Orc\S\Process\01", "G:\Orc\S\Process\Backups\Backup\00Custos_tabelas_ gerais.mdb"
    FileCopy "G:\Orc\S\Process\02", "G:\Orc\S\Process\Backups\Backup\00Custos_tabelas_ gerais.mdb"
    FileCopy "G:\Orc\S\Process\03", "G:\Orc\S\Process\Backups\Backup\00Custos_tabelas_ gerais.mdb"
    FileCopy "G:\Orc\S\Process\04", "G:\Orc\S\Process\Backups\Backup\00Custos_tabelas_ gerais.mdb"


    'zip

    folder_destiny = "G:\OrcControlo\SCC\Processo\Backups\" & year_n & "\"


    folder_to_zip= "G:\OrcControlo\SCC\Processo\Backups\" & year_n


    name_zip = folder_destiny & "Custos_" & ano & mes & ".zip"


    'Criar um arquivo zip vazio
    Call Novo_zip_vazio(nome_zip)


    Set oApp = CreateObject("Shell.Application")


    oApp.NameSpace(name_zip).CopyHere oApp.NameSpace(folder_to_zip).Items


    'Aguardar o término da compactação
    On Error Resume Next
    Do Until oApp.NameSpace(nome_zip).Items.Count = oApp.NameSpace(pasta_a_zipar).Items.Count
    'Application.Wait (Now + TimeValue("0:00:01"))
    Loop
    On Error GoTo 0

    Kill "G:\OrcControlo\SCC\Processo\Backups\" & ano & "\" & year_n & month_n & "\*.*" ' delete all files in the folder
    RmDir "G:\OrcControlo\SCC\Processo\Backups\" & year_n & "\" & year_n & month_n ' delete folder




    End Sub






    Sub New_zip(sPath)
    If Len(Dir(sPath)) > 0 Then Kill sPath
    Open sPath For Output As #1
    Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
    Close #1
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    What is issue? You have code so what happens - error message, wrong results, nothing?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    joanas is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    9
    the code works. but it takes a lot of time.. because it does the security copy first. there is a way to do just the zip ?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Here's what I use:

    'create empty zip folder
    'found this on web, no idea what the Print line does but if it isn't there, this won't work
    Dim strZip As String
    strZip = "path\zip file name here"
    Open strZip For Output As #1
    Print #1, "PK" & Chr$(5) & Chr$(6) & String(18, 0)
    Close #1
    'copy file into zip folder
    Dim objApp As Object
    Set objApp = CreateObject("Shell.Application")
    'variable for source file doesn't seem to work in this line; also double parens not in original example code but won't work without
    objApp.NameSpace((strZip)).CopyHere gstrBasePath & "Program\Editing\ConstructionExtract.accdb"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. using mdb files which are backed up hourly into zip files
    By Robbie MacKinnon in forum Access
    Replies: 3
    Last Post: 05-05-2015, 05:02 AM
  2. Replies: 4
    Last Post: 05-15-2014, 12:49 PM
  3. PDF OLE files
    By sam1 in forum Access
    Replies: 0
    Last Post: 11-24-2011, 07:26 AM
  4. Replies: 1
    Last Post: 02-21-2011, 09:55 PM
  5. Attaching Files
    By jlclark4 in forum Forms
    Replies: 7
    Last Post: 01-20-2011, 03:01 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums