Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS Access VBA to Zip two files

Posted on 2013-06-04
2
Medium Priority
?
576 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

971 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