thread181-1493416
I'm using the following code"
Public Sub CreateEmptyZip(sPath)
Dim strZIPHeader As String
' header required to convince Windows shell that this is really a zip file
strZIPHeader = Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
MsgBox "strZipHeader = " & strZIPHeader, vbInformation, "DevNote"
With CreateObject("Scripting.FileSystemObject")
.CreateTextFile(sPath).Write strZIPHeader
End With
End Sub
Private Sub cmdZipThenUploadFTP_Click()
'On Error GoTo Err_Handler
'zip code from Tek-tips thread181-1493416
Dim blnSuccess As Boolean
' True if successful, false if not
'Ok, easiest is to first create a blank zip file and then use the copyhere command to copy the files into it. To create a blank zip use something like:
DoCmd.Hourglass True
CreateEmptyZip "C:\Program Files\Bill Pro\BillProTest.zip"
With CreateObject("Shell.Application")
' Copy a file into the compressed folder.
.NameSpace("C:\Program Files\Bill Pro\BillProTest.zip").CopyHere _
"C:\Program Files\Bill Pro\BillPro_be.mdb"
'use this line if we want to zip all items in a folder into our zip file
'.NameSpace("c:\myDir\testzip.zip").CopyHere .NameSpace("C:\myDir\Files").Items
End With
'now upload to FTP
'example of call
'blnSuccess = 'FTPUploadFile(ByVal HostName As String, ByVal UserName As String, ByVal Password As String, byVal LocalFileName As String, ByVal RemoteFileName As String, ByVal sDir As String, ByVal sMode As String) As Boolean
blnSuccess = FTPUploadFile(" "datatrieve", "xxxx", "C:\Program Files\Bill Pro\BillProTest.zip", " "uploads", "Binary")
DoCmd.Hourglass False
If blnSuccess Then
MsgBox "FTP Zip & Upload completed.", vbInformation, "Success"
Else
MsgBox "FTP Zip & Upload failed.", vbCritical, "Warning"
End If
The FTPUpload works fine by itself. However, when I run the zip routine I have a problem. If I create the empty zip file (commenting out the NameSpace code that inserts the target file) the 'empty' zipfile uploads fine. Once I try to copy any real file (.txt or .mdb) into the empty zipfile the Upload code always fails. The file gets inserted into the empty zipfile (I can later extract it) but the send fails. Any ideas?
I'm using the following code"
Public Sub CreateEmptyZip(sPath)
Dim strZIPHeader As String
' header required to convince Windows shell that this is really a zip file
strZIPHeader = Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
MsgBox "strZipHeader = " & strZIPHeader, vbInformation, "DevNote"
With CreateObject("Scripting.FileSystemObject")
.CreateTextFile(sPath).Write strZIPHeader
End With
End Sub
Private Sub cmdZipThenUploadFTP_Click()
'On Error GoTo Err_Handler
'zip code from Tek-tips thread181-1493416
Dim blnSuccess As Boolean
' True if successful, false if not
'Ok, easiest is to first create a blank zip file and then use the copyhere command to copy the files into it. To create a blank zip use something like:
DoCmd.Hourglass True
CreateEmptyZip "C:\Program Files\Bill Pro\BillProTest.zip"
With CreateObject("Shell.Application")
' Copy a file into the compressed folder.
.NameSpace("C:\Program Files\Bill Pro\BillProTest.zip").CopyHere _
"C:\Program Files\Bill Pro\BillPro_be.mdb"
'use this line if we want to zip all items in a folder into our zip file
'.NameSpace("c:\myDir\testzip.zip").CopyHere .NameSpace("C:\myDir\Files").Items
End With
'now upload to FTP
'example of call
'blnSuccess = 'FTPUploadFile(ByVal HostName As String, ByVal UserName As String, ByVal Password As String, byVal LocalFileName As String, ByVal RemoteFileName As String, ByVal sDir As String, ByVal sMode As String) As Boolean
blnSuccess = FTPUploadFile(" "datatrieve", "xxxx", "C:\Program Files\Bill Pro\BillProTest.zip", " "uploads", "Binary")
DoCmd.Hourglass False
If blnSuccess Then
MsgBox "FTP Zip & Upload completed.", vbInformation, "Success"
Else
MsgBox "FTP Zip & Upload failed.", vbCritical, "Warning"
End If
The FTPUpload works fine by itself. However, when I run the zip routine I have a problem. If I create the empty zip file (commenting out the NameSpace code that inserts the target file) the 'empty' zipfile uploads fine. Once I try to copy any real file (.txt or .mdb) into the empty zipfile the Upload code always fails. The file gets inserted into the empty zipfile (I can later extract it) but the send fails. Any ideas?