Solved

MS Access VBA to Zip two files

Posted on 2013-06-04
2
503 Views
Last Modified: 2013-06-12
Hello Experts,
I just want to zip two files but the code below receives an error message, “Object variable or With block variable not set”.  Can you please help?

Private Sub Zip_Click()
Dim SourceTable As String
    Set db = CurrentDb

Set oApp = CreateObject("Shell.Application")
    pathname = "H:\Email\"
    NewZip (pathname & "Test.zip")
 
    oApp.NameSpace(pathname & "1.zip").CopyHere "H:\Email\MonthlyParplanDetail.xls"
    oApp.NameSpace(pathname & "2.zip").CopyHere "H:\Email\MonthlyParplanDetail.pdf"
    oApp.NameSpace(pathname & "3.zip").CopyHere pathname & "item_settings.zip"
    Set oApp = Nothing
   
    MsgBox "Zipped"
End Sub
0
Comment
Question by:CFMI
2 Comments
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 500 total points
ID: 39219816
Your code does not appear to be complete.

Try  this code:  http://accessexperts.com/blog/2012/02/06/zipandunzipfrommicrosoftvba/

Also see:
http://www.rondebruin.nl/win/section7.htm
0
 
LVL 1

Author Closing Comment

by:CFMI
ID: 39240810
Excellent as the material helped me derive the correct code to zip multiple files and my learning was to include time (Pause between events) for compacting.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now