
Using PKZip or WinZip from within Access
If you are sending files via email or saving files to a floppy disk, then you will probably want to ensure that the file is as small as possible. You can compress files using one of the zipping programs available, either WinZip or PKZip. If you want to automate these from Access, then you should get the command line version of either of these. In addition, you may find the following links useful when running in a MS-DOS window:
Shell and Wait - As the shell command in Access does not wait for the shelled process to finish, you will probably want to use some means of halting code execution until the process does finish, especially if you are expecting to use the file further on in your code.
Get Short and Long File Names - As you are working with Windows files in a MS-DOS environment, you will probably need to convert any Windows file names to their MS-DOS equivalents.
Below is a sample function, using WinZip to zip a file, utilising the functions described on the two links above:
Function fWinZip(strFile2Zip As String) As String
On Error GoTo E_Handle
Dim strWZipPath As String
Dim strZippedFile As String
Dim strZipCmd As String
strWZipPath = "C:\Access Dev\wzzip.exe"
strZippedFile = Left(strFile2Zip, InStr(strFile2Zip, ".")) & "zip"
strZipCmd = " -a -ex "
strWZipPath = fGetShortName(strWZipPath)
strFile2Zip = fGetShortName(strFile2Zip)
strZippedFile = fGetShortName(strZippedFile)
ExecCmd strWZipPath & strZipCmd & strZippedFile & " " & strFile2Zip
fWinZip = strZippedFile
fExit:
On Error Resume Next
Exit Function
E_Handle:
MsgBox Err.Description & vbCrLf & "fWinZip", vbOKOnly + vbCritical, "Error: " & Err.Number
Resume fExit
End Function
|
Top
HOME |
NEW |
TABLES |
QUERIES |
FORMS |
REPORTS |
GENERAL |
API |
DOWNLOADS |
TUTORIAL |
RESOURCES
E-MAIL
Copyright & Disclaimer
|