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
Solved

MS Access VBA to Zip two files

Posted on 2013-06-04
2
522 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

856 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