?
Solved

MS Access VBA to Zip two files

Posted on 2013-06-04
2
Medium Priority
?
555 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

762 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