Solved

MS Access VBA to Zip two files

Posted on 2013-06-04
2
465 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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,…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

728 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

13 Experts available now in Live!

Get 1:1 Help Now