Zipping a file from VBA

ianclegg

Registered User.
Local time
Today, 07:42
Joined
Jul 14, 2001
Messages
58
Can anybody point me in the right direction?

I am trying to zip a file that I have exported as a csv file from a form in access.

The file exports ok but the zipping is a problem.

I have used the code suggested by keiths and is listed below

Dim objzip
Set objzip = CreateObject("poles.zip")
objzip.Pack "c:/exporteddata/poles.csv", "c:/exporteddata/poles.zip"
Set objzip = Nothing

I hope I have interpreted it correctly, the error message I am getting is unable to create object.

I have followed the installation procedure for XStandard Zip component and It appears to have installed ok.

Any help would be much appreciated.


Regards

Ian Clegg
 
This works in Access 07 under Windows 7

Code:
Sub CreateAndLoadZipfileTest()
   Dim spec As String
   spec = "C:\YourZipfile.zip"

[COLOR="Green"]   'creates the zip file[/COLOR]
   Open spec For Binary Access Write As #1
   Close #1

[COLOR="Green"]   'copies other file into zip file[/COLOR]   
   Dim shl As New Shell32.Shell
   shl.Namespace(spec).CopyHere "C:\YourCsvFile.csv"

End Sub
 

Users who are viewing this thread

Back
Top Bottom