Zip Files and Copy to FTP site

M

Manuel

Hi:

I'l like to find code which could do the following:

1). Zip up two Excel files on the nextwork
2). FTP Zip file to vendors FTP website: ftp://ftp.VENDOR.com/incoming/

Can I do this with VBA code in Access 2003?

Thanks in advance for you assistance.

Manuel
 
K

Klatuu

Yes, you can do it in VBA, but it involves shelling out to a couple of
routines.
To zip the file, you will need to get the command line version of WinZip to
zip your files. Then, to do the ftp, you can shell out to ftp with a scipt
file containing the commands.
 
M

Manuel

Thanks, good to know that it can be done.

Would you be able to point me to some sample code?

Manuel
 
B

BeWyched

Hi

You can easily create a Zip file using:

Open "\path to folder\zip folder name.zip" For Output As #1
Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
Close #1

The Open line creates the file. The Print line prints a line into the file's
header that tells Windows its a compressed file. Note that if you are using
the Vista O/S then, so long as the file extension is .zip, you don't need the
Print line.

Then just copy the files to the zip file using VBA and they will be zipped.

Re the FTP query. See the other posts. Personally, I use an proprietory FTP
client produced by Evans FTP which works very well.

Cheers.

BW
 
S

Stuart McCall

BeWyched said:
Hi

You can easily create a Zip file using:

Open "\path to folder\zip folder name.zip" For Output As #1
Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
Close #1

The Open line creates the file. The Print line prints a line into the
file's
header that tells Windows its a compressed file. Note that if you are
using
the Vista O/S then, so long as the file extension is .zip, you don't need
the
Print line.

Then just copy the files to the zip file using VBA and they will be
zipped.

You can't use the FileCopy method to copy a file into a zipfile namespace.
You need to use the shell, like this:

Public Function CopyFileToZip(ZipFileName, FileToCopy) As Long
On Error GoTo Out
'
With CreateObject("Shell.Application").NameSpace(ZipFileName)
.CopyHere FileToCopy
End With
Out:
CopyFileToZip = Err.Number
End Function

Also be aware that a sysadmin may 'switch off' compressed folders, which
disables this method altogether.
 
T

Tony Toews [MVP]

Manuel said:
1). Zip up two Excel files on the nextwork

You already have some answers but in my opinion your best answer for
zipping is to use the free, open source Info zip dlls. They will give
you more feedback and better error handling than shelling out.

Compression DLLs, OCXs, etc
http://www.granite.ab.ca/access/compression.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
R

Rob

Hello Albert, with the 'VBA libary of ftp' you pointed to...is it possible to
download/upload multiple files? (specified or wild carded?)
I only found out how to transport one file at a time, involving connecting
and deconnecting for each file.

Maybe you can give me a hint how to do it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top