Results 1 to 2 of 2
  1. #1
    SexyHerdie is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2019
    Posts
    1

    Zip a file using VBA in MS Access 2013

    Dear Access Experts,



    I'm a newbie and I want to know how can I put in some code that would compress an Access database in a zip file. Can you help me please?

    Thank you.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Here is what I use:

    Code:
    Option Compare Database
    Option Explicit
    Global Const gstrBasePath = "C:\Users\June\"
    ___________
    Dim strZip As String
    Dim objApp As Object
    strZip = gstrBasePath & "Editing\ConstructionExtract.zip"
    '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
    Open strZip For Output As #1
    Print #1, "PK" & Chr$(5) & Chr$(6) & String(18, 0)
    Close #1
    Set objApp = CreateObject("Shell.Application")
    'copy file into zip folder
    '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 & "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. Access 2013 Macro to clear CSV file
    By m698322h in forum Access
    Replies: 3
    Last Post: 02-15-2016, 02:08 PM
  2. Replies: 4
    Last Post: 10-04-2015, 02:04 PM
  3. Replies: 2
    Last Post: 08-13-2015, 02:14 PM
  4. PDF File content display on Access 2013 form
    By saleemsadique in forum Access
    Replies: 7
    Last Post: 02-07-2014, 06:36 PM
  5. XML file opens in excel 2010/2013 correctly but not in Access
    By flebber in forum Import/Export Data
    Replies: 1
    Last Post: 05-21-2013, 09:23 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