I need to find a free way to zip up some files in my access program. I currently am using winzip but not all customers have winzip. I've found peazip but am having a hard time figuring out the command line prompts. Does anybody know of zip program and can show me the command line or has anybody used peazip and can show me the command line.
Thanks for any help.
40 3390
Have a look at basZip by Ken Jensen. It works quite well. Requires four modules:
basZip
(classes)
khZip
khZipFile
khZipFiles
Where do I find basZip I tried a web search but don't get anything.
zmbd 5,501
Expert Mod 4TB
CDTom: Out of curiosity; are you storing the files within the database, not normally a good idea, or is the database compressing files on the user's PC.
You also need to be very aware of the fact that anything you find "free" on the internet may have usage restrictions when applied to your situation. In fact, many either prohibt the use of their product with/within other programs or for commercial usage. All of the pay-for type programs will have such restrictions - they want you to pay for their product.
I'm extracting three .csv files out of the database and then want to zip up those three file so they can be emailed.
Here you go. So you will be inserting one standard module and three class modules. Study how this works and if you need assistance let me know. My implementation exports 3 tables as XML to a temp directory, zips them, deletes the individual XML files and emails the zip file. Bytes users helped me get it setup.
I understand that these need to go into my database but for some reason I can figure out how. I've tried creating a new cls module and then importing them in but nothing show up. What am I doing wrong?
First you need to unzip your files.
From your VBA editor: click file menu --> import file
From Access 2010 (different in earlier versions): click external data menu, from the import and link panel, select Access. In this screen you want to import, not link to the files. Navigate to your files and select.
I figured out and got them loaded now I need to figure out how to use them. If you can give some code examples I would appreciate it. Thanks
I ran a compile on the program and I get an error on some of the private statements in the khZip - Private mobjZipFile as khZipFiles
the error I get is User-defined type not defined.
I changed the module name from khZipfile to khZipfiles and that seemed to take care of the error. However now when I run the compile I get another error in the BasZip module when I uncomment the files I get the error Method or data member not found on the .Add in the .ZipFiles any ideas?
I think this was all my error I didn't download all the files you sent sorry about that.
PeaZip is LGPL, so it is free without limitation and unlike GPL can be used both in open or closed source third party works.
In the online help file there are examples of use from command line, and it goes even further as it has a Console tab when you are defining tasks so you can save whatever you are doing to a script.
Ok now that I have this without any errors (sorry about my mess up) How do I run this, I've tried doing a
but it doesn't do anything. Must be something with me as usual.
bb80
I've been working with the Peazip and trying to get it to work. I've created a .bat file to test with but never get and file. The .bat file looks like this - Start "C:\program files\peazip\peazip.exe -add2zip extractdata.csv extractcat.csv extractparm.csv
I don't get any errors but now .zip file is created. Do you know anything about Peazip the you might be able to help me. I would like to put this into my code but don't know how. Any help would be appreciated.
Thanks
CD Tom:
This is how I call it: -
Dim mzipfile As khZip
-
Dim strSavePath, strZipDir As String
-
-
strZipDir = BrowseFolder("Next - Choose Folder For Export")
-
-
MyZipFileName = <your file name here>
-
-
Set mzipfile = New khZip
-
With mzipfile
-
.ZipFilePath = strZipDir & "\" & MyZipFileName
-
'save full path to zip for email purposes
-
strSavePath = .ZipFilePath
-
.ZipFolderPath = strTempDir
-
.ZipAll
-
End With
-
Attached is the BrowseFolder code if you need it. Unzip and import that into a standard module. Then copy/paste this code below into another standard module: -
Option Compare Database
-
Option Explicit
-
-
'************** Code Start **************
-
'This code was originally written by Terry Kreft.
-
'It is not to be altered or distributed,
-
'except as part of an application.
-
'You are free to use it in any application,
-
'provided the copyright notice is left unchanged.
-
'
-
'Code courtesy of
-
'Terry Kreft
-
-
Private Type BROWSEINFO
-
hOwner As Long
-
pidlRoot As Long
-
pszDisplayName As String
-
lpszTitle As String
-
ulFlags As Long
-
lpfn As Long
-
lParam As Long
-
iImage As Long
-
End Type
-
-
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
-
"SHGetPathFromIDListA" (ByVal pidl As Long, _
-
ByVal pszPath As String) As Long
-
-
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
-
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
-
As Long
-
-
Private Const BIF_RETURNONLYFSDIRS = &H1
-
Public Function BrowseFolder(szDialogTitle As String) As String
-
Dim x As Long, bi As BROWSEINFO, dwIList As Long
-
Dim szPath As String, wPos As Integer
-
-
With bi
-
.hOwner = hWndAccessApp
-
.lpszTitle = szDialogTitle
-
.ulFlags = BIF_RETURNONLYFSDIRS
-
End With
-
-
dwIList = SHBrowseForFolder(bi)
-
szPath = Space$(512)
-
x = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
-
-
If x Then
-
wPos = InStr(szPath, Chr(0))
-
BrowseFolder = left$(szPath, wPos - 1)
-
Else
-
BrowseFolder = vbNullString
-
End If
-
End Function
-
'*********** Code End *****************
-
-
And it should work.
NeoPa 32,556
Expert Mod 16PB
I appreciate you have a preference for PeaZip Tom, but I feel I have to offer the opportunity of using WinZip's command line utility. Principally because it's what I used and can create standard .ZIP files from a command line interface (I expect others can do too, but this is what I set up to use on my systems).
The software needs to be installed to use, but the code that uses it will determine if it's available before calling it. Here's the code I use : - 'Zip zips up the files in strFiles into strZip. Returns success state.
-
Public Function Zip(strZip As String, strFiles As String) As Boolean
-
Dim strCMD As String, strExe As String
-
-
Zip = True
-
On Error GoTo ErrorZ
-
strExe = RegRead(conHKLM, conZipKey, "")
-
strCMD = Replace("""%E"" -a+ -ex -ybc ""%Z"" ""%F""", "%E", strExe)
-
strCMD = Replace(strCMD, "%Z", strZip)
-
strCMD = Replace(strCMD, "%F", strFiles)
-
Call Shell(PathName:=strCMD, WindowStyle:=vbNormalFocus)
-
Exit Function
-
-
ErrorZ:
-
strCMD = Replace("Unable to zip {%F} into '%Z'", "%F", strFiles)
-
strCMD = Replace(strCMD, "%Z", strZip)
-
Call ShowMsg(strMsg:=strCMD, strTitle:="Zip", intButtons:=vbInformation)
-
Zip = False
-
End Function
RegRead is just one of many such procedures found all over the place, but in case you don't have one here's what I use (Stripped to what's required here) : - Option Compare Database
-
Option Explicit
-
-
'Windows API Variable Prefixes
-
'cb = Count of Bytes (32-bit)
-
'w = Word (16-bit)
-
'dw = Double Word (32-bit)
-
'lp = Long Pointer (32-bit)
-
'b = Boolean (32-bit)
-
'h = Handle (32-bit)
-
'ul = Unsigned Long (32-bit)
-
-
Public Const conHKLM = &H80000002
-
Public Const REG_NONE As Long = 0 'None
-
Public Const REG_SZ As Long = 1 'Null terminated string
-
Public Const REG_EXPAND_SZ As Long = 2 'As above but contains
-
' unexpanded Env Vars
-
Public Const REG_BINARY As Long = 3 'binary data
-
Public Const REG_DWORD As Long = 4 'Double Word (Long)
-
Public Const REG_DWORD_BIG_ENDIAN As Long = 5 'As above but reversed
-
Public Const REG_LINK As Long = 6 'Unicode symbolic link
-
Public Const REG_MULTI_SZ As Long = 7 'Array of SZs (dbl null ends)
-
Public Const REG_RESOURCE_LIST As Long = 8
-
Public Const REG_FULL_RESOURCE_DESCRIPTOR As Long = 9
-
Public Const REG_RESOURCE_REQUIREMENTS_LIST As Long = 10
-
Public Const REG_QWORD As Long = 11 ' Quad Word
-
Public Const conStandardRightsAll = &H1F0000
-
Public Const conReadControl = &H20000
-
Public Const conStandardRightsRead = (conReadControl)
-
Public Const conRegSz = 1
-
Public Const conOK = 0&
-
Public Const conKeyQueryValue = &H1
-
Public Const conKeySetValue = &H2
-
Public Const conKeyCreateSubKey = &H4
-
Public Const conKeyEnumerateSubKeys = &H8
-
Public Const conKeyNotify = &H10
-
Public Const conKeyCreateLink = &H20
-
Public Const conSynchronise = &H100000
-
Public Const conRegOptionNonVolatile = 0
-
Public Const conKeyAllAccess = ((conStandardRightsAll _
-
Or conKeyQueryValue _
-
Or conKeySetValue _
-
Or conKeyCreateSubKey _
-
Or conKeyEnumerateSubKeys _
-
Or conKeyNotify _
-
Or conKeyCreateLink) _
-
And (Not conSynchronise))
-
Public Const conKeyRead = ((conReadControl _
-
Or conKeyQueryValue _
-
Or conKeyEnumerateSubKeys _
-
Or conKeyNotify) _
-
And (Not conSynchronise))
-
-
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
-
Alias "RegOpenKeyExA" (ByVal hKey As Long, _
-
ByVal lpSubKey As String, _
-
ByVal ulOptions As Long, _
-
ByVal samDesired As Long, _
-
phkResult As Long) As Long
-
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) _
-
As Long
-
Private Declare Function RegQueryValueExStr Lib "advapi32.dll" _
-
Alias "RegQueryValueExA" (ByVal hKey As Long, _
-
ByVal lpValueName As String, _
-
ByVal lpReserved As Long, _
-
ByRef lpType As Long, _
-
ByVal lpData As String, _
-
ByRef lpcbData As Long) As Long
-
-
Public Function RegRead(ByVal lngHive As Long, _
-
ByVal strKey As String, _
-
ByVal strValue As String) As Variant
-
Dim intX As Integer
-
Dim strBuf As String
-
Dim lngRet As Long, lngHKey As Long, lngType As Long, lngBufLen As Long
-
-
RegRead = Null
-
strKey = strKey & vbNullChar
-
lngRet = RegOpenKeyEx(hKey:=lngHive, _
-
lpSubKey:=strKey, _
-
ulOptions:=0, _
-
samDesired:=conKeyRead, _
-
phkResult:=lngHKey)
-
If lngRet = conOK Then
-
'Set up buffer to store value
-
lngBufLen = 255
-
strBuf = String(lngBufLen, 0)
-
strValue = strValue & vbNullChar
-
lngRet = RegQueryValueExStr(hKey:=lngHKey, _
-
lpValueName:=strValue, _
-
lpReserved:=0&, _
-
lpType:=lngType, _
-
lpData:=strBuf, _
-
lpcbData:=lngBufLen)
-
'Close key
-
Call RegCloseKey(lngHKey)
-
Select Case lngType
-
Case REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ, REG_BINARY
-
If lngBufLen = 255 Then
-
RegRead = Null
-
Else
-
If lngType <> REG_BINARY Then lngBufLen = lngBufLen - 1
-
RegRead = Left(strBuf, lngBufLen)
-
If lngType = REG_MULTI_SZ Then _
-
RegRead = Split(RegRead, vbNullChar)
-
End If
-
Case REG_DWORD
-
For intX = 4 To 1 Step -1
-
lngRet = Asc(Mid(strBuf, intX))
-
If intX = 4 Then
-
If (lngRet And &H80) > 0 Then
-
RegRead = &H80000000
-
lngRet = (lngRet And &H7F)
-
Else
-
RegRead = 0
-
End If
-
End If
-
RegRead = RegRead Or (lngRet * 256 ^ (intX - 1))
-
Next intX
-
End Select
-
End If
-
End Function
zmbd 5,501
Expert Mod 4TB
Since WinXP - zip files using the deflate compression have been native to the OS as compressed folders. Isn't there an API call (honestly, I don't know - just curious) that we could use to create and manipulate "compressed" folders?
NeoPa 32,556
Expert Mod 16PB
I don't know either Z :-(
I'm not sure that would answer the requirements of the question though. ZIP files are used outside of Windows, and have been used for many years as a standard for transferring files from one system (person) to another. They have a level of ubiquity (ubiquitousness?) unmatched elsewhere.
While it may not be important for this OP (I don't know), it will still be interesting for many readers to learn about ways of using ZIP files specifically.
NB. That doesn't mean Win compressed files are not interesting or relevant. Just that ZIP files are the main thrust of the question and we need to ensure they are covered fully, even if Win compressed files provide an acceptable alternative for this OP.
zmbd 5,501
Expert Mod 4TB
I understand. The folder/zip-file in WinXP, etc... is still a zip file and therefor shown as such in the file explorers. However, if you double click on the zipfile, you can use it like any other directory (haven't tried mapping a drive to one; however, I don't think that'll work).
IN anycase, if there was an API call to the WIN32 or one of the other DLL that'd allow the creation of the file and subsequent manipulation - that might fullfill OP request.
Something to look into in the near future.
NeoPa 32,556
Expert Mod 16PB Zmbd:
IN anycase, if there was an API call to the WIN32 or one of the other DLL that'd allow the creation of the file and subsequent manipulation - that might fullfill OP request.
Indeed. I was showing my ignorance it seems :-( If it can create a standard ZIP file, and is relatively easy to accomplish in code, then it would certainly suit both the OP and the main question :-)
Tuxalot,
Thanks but I still have a problem, When I reach the line
I get an error automation error. What am I doing wrong.
I do have this working with Winzip but because some users don't have winzip I'm looking for a way where they don't have to purchase it. It looks like tuxalot may have the answer if I can get it to work.
Thanks
tuxalot,
I'll try and give you more details on the error. When it hits the above line it goes to khZip Module to the Private Sub Class_initalize and again when it hits the line - Set mobjZipFile = New khZipFile
it jumps to the err_class_initialize and then I get the error. Maybe this will help more.
I'm running Windows 7 but some of my users are using Windows XP I guess I should ask does this work in Windows 7?
NeoPa 32,556
Expert Mod 16PB CD Tom:
I guess I should ask does this work in Windows 7?
When you do, be sure to specify what you mean by this ;-)
Yes you are correct I was thinking about tuxalot zip program and forgot about everybody else that was in on this. Sorry
I'm still running into an error Automation error and can't figure out why here's the code - Set mzipfile = New khZip
-
With mzipfile
-
.zipFilePath = strfoldername + "\" & MyZipFileName
-
.zipfiles.add strfoldername + "\extractcat.csv"
-
.zipfiles.add strfoldername + "\extractdata.csv"
-
.zipfiles.add strfoldername + "\extractparm.csv
-
.zip
-
End with
when code reaches the line 1 it jumps to the khZip code - Private Sub Class_Initialize()
-
on error goto err_class_initialize
-
set mobjZipFile = New khZipFile
-
exit_Class_initialize:
-
exit sub
-
err_Class_Initialize:
-
err.raise err.number, err.source & " - ActlZip - Class_initialize " & erl, err.description
-
Resume Exit_Class_initialize
code reaches the set statement and jumps to the error and I get the automation error.
Any help would sure be appreciated
Thanks
Hope you had a Merry Christmas
NeoPa 32,556
Expert Mod 16PB
You cannot make a call to Class_Initialize(), from within Class_Initialize().
Line #3 of Class_Initialize() attempts to do this. It's not logical that you should even want to TBF.
PS. I beg your pardon! That is not the case here as one is New khZip while the other is New khZipFile. However, as we have no information pertaining to whether or not you even have a Class_Initialize() for New khZipFile, we cannot say exactly what may be going wrong there.
This is the code the Tuxalot sent me and I'm trying to get it to work. Tuxalot sent me some modules to put into my code to get the zip to work. I've entered this code and when I run it I get the error mentioned. I was trying to get back to Tuxalot and see if he/she could help me.
NeoPa 32,556
Expert Mod 16PB
Well, Tom, that may make sense from your perspective, but there are a lot of things wrong with that approach.
The site, which provides the means for you to get free help when you need it, will not benefit from threads where some of the information is public and some of it not included publicly. In fact it will suffer, as people looking for answers to similar questions try to follow the thread but get lost due to missing information. They leave in disgust and the site is marked down by the SEs (Google etc).
Other experts are already involved in the thread. Unless you feel you have the right to determine who may, and who may not, respond to your questions in a public thread owned by the site, then these experts also deserve the respect of your including all the relevant information required to understand, and therefore help with, your problem.
Please don't think I'm trying to slam you for not perceiving these nuances. I don't expect most members to appreciate some of these niceties, so your not doing so can hardly be criticised. Nevertheless they are true, and we would ask that you bear them in mind and make all relevant information available to the thread as a whole so that all may understand and benefit from the troubles you're experiencing at this time. Others will almost certainly want to benefit from the solutions found in here at later dates. Please understand that this is a moderator request, as full relevant disclosure is a requirement for participating on this site.
A point to bear in mind (and we on the experts side always do) is that any individual expert or helper may go on holiday or be otherwise unavailable for an extended period half way through any number of threads. It does no-one any good if these threads are left in limbo during that time. Now is a particularly likely period through which members may have extended absences.
Line #3 in your Class_Initialize() procedure is clearly where the problem occurs. Without knowing what you have in your project to handle this, no-one will be able to follow the problem. Even Tux can only guess how well you have incorporated the code he made available to you. You certainly wouldn't be the first member to fail to incorporate suggestions, and even code blocks provided for you, incorrectly.
I didn't realize you couldn't answer to an individual. Your explanation makes sense and I will be more careful in the future.
Thanks for the heads up.
NeoPa 32,556
Expert Mod 16PB
Fair dos.
Can you post what you have for the class khZipFile please.
Ok, here's where it starts: - Dim mzipfile As khZip
-
Dim StrSavePath, StrZipDir As String
-
Set mzipfile = New khZip
-
With mzipfile
-
'zip chosen files
-
.ZipFilePath = strfoldername + "\" & MyZipFileName
-
.ZipFiles.Add strfoldername + "\extractcat.csv"
-
.ZipFiles.Add strfoldername + "\extractdata.csv"
-
.ZipFiles.Add strfoldername + "\extractparm.csv"
-
.Zip
-
End With
-
Here is the modules khZip - '---------------------------------------------------------------------------------------
-
' Module : khZip
-
' DateTime : 5/18/2007 14:02
-
' Author : Ken Jensen
-
' Purpose : Automate the Windows XP zip functionality
-
'---------------------------------------------------------------------------------------
-
Option Compare Database
-
Option Explicit
-
Private Const ERRSOURCE As String = "Zip"
-
-
Private mobjZipFile As khZipFiles
-
Private mstrZipFilePath As String
-
Private mstrUnzipFolderPath As String
-
Private mstrZipFolderPath As String
-
Private mstrZipFilePath_Temp As String
-
-
Public Property Get ZipFilePath() As String
-
ZipFilePath = mstrZipFilePath
-
End Property
-
-
Public Property Let ZipFilePath(strZipFilePathIn As String)
-
mstrZipFilePath = strZipFilePathIn
-
End Property
-
-
Private Sub Class_Initialize()
-
-
On Error GoTo Err_Class_Initialize
-
-
Set mobjZipFile = New khZipFile
-
-
Exit_Class_Initialize:
-
Exit Sub
-
-
Err_Class_Initialize:
-
Err.Raise Err.Number, Err.Source & " - ActlZip - Class_Initialize " & Erl, Err.Description
-
Resume Exit_Class_Initialize
-
-
End Sub
-
-
Public Sub Zip()
-
-
On Error GoTo Err_Zip
-
-
Dim objShell As Object
-
Dim objFolder As Object
-
-
Dim lngCnt As Long
-
-
If IsNull(Me.ZipFilePath) Then
-
MsgBox "You must include a path for the zip file", vbOKOnly + vbExclamation
-
Else
-
If mobjZipFile.Count < 1 Then
-
MsgBox "You must include at least one file to be zipped", vbOKOnly + vbExclamation
-
Else
-
NewZip Me.ZipFilePath
-
-
Set objShell = CreateObject("Shell.Application")
-
Set objFolder = objShell.NameSpace(Me.ZipFilePath)
-
-
For lngCnt = 1 To mobjZipFile.Count
-
objFolder.CopyHere mobjZipFile.ZipFileString(lngCnt)
-
Next lngCnt
-
-
'Keep script waiting until Compressing is done
-
On Error Resume Next
-
Do Until objFolder.Items.Count = lngCnt - 1
-
DoEvents
-
Loop
-
-
On Error GoTo Err_Zip
-
End If
-
End If
-
-
Exit_Zip:
-
Set objShell = Nothing
-
Set objFolder = Nothing
-
Exit Sub
-
-
Err_Zip:
-
Err.Raise Err.Number, Err.Source & " - khZip - Zip " & Erl, Err.Description
-
Resume Exit_Zip
-
-
End Sub
-
-
Public Sub UnZipAll()
-
-
On Error GoTo Err_UnZipAll
-
-
Dim objShell As Object
-
-
Set objShell = CreateObject("Shell.Application")
-
-
objShell.NameSpace(Me.UnzipFolderPath).CopyHere objShell.NameSpace(Me.ZipFilePath).Items
-
-
Exit_UnZipAll:
-
Set objShell = Nothing
-
Exit Sub
-
-
Err_UnZipAll:
-
Err.Raise Err.Number, Err.Source & " - khZip - UnZipAll " & Erl, Err.Description
-
Resume Exit_UnZipAll
-
-
End Sub
-
-
Public Sub ZipAll()
-
-
On Error GoTo Err_ZipAll
-
-
Dim objShell As Object
-
Dim objFolder As Object
-
Dim objFolder2 As Object
-
Dim tmpFolder As String
-
-
If IsNull(Me.ZipFilePath) Then
-
MsgBox "You must include a path for the zip file", vbOKOnly + vbExclamation
-
Else
-
'create temp file then move after zipping
-
'issue when try to zip all files in folder if zip file is placed in same folder
-
-
-
tmpFolder = "C:\Temp" & "\"
-
-
If Dir(tmpFolder) = "" Then
-
On Error Resume Next
-
MkDir tmpFolder
-
End If
-
On Error GoTo Err_ZipAll
-
-
Me.ZipFilePath_Temp = "C:\Temp\" & Right$(Me.ZipFilePath, Len(Me.ZipFilePath) - InStrRev(Me.ZipFilePath, "\"))
-
-
NewZip Me.ZipFilePath_Temp
-
-
If Right$(Me.ZipFolderPath, 1) <> "\" Then
-
Me.ZipFolderPath = Me.ZipFolderPath & "\"
-
End If
-
-
Set objShell = CreateObject("Shell.Application")
-
Set objFolder = objShell.NameSpace(Me.ZipFilePath_Temp)
-
Set objFolder2 = objShell.NameSpace(Me.ZipFolderPath)
-
-
objFolder.CopyHere objFolder2.Items
-
-
'Keep script waiting until Compressing is done
-
On Error Resume Next
-
Do Until objFolder.Items.Count = objFolder2.Items.Count
-
DoEvents
-
Loop
-
-
On Error GoTo Err_ZipAll
-
-
If Len(Dir(Me.ZipFilePath)) > 0 Then
-
Kill Me.ZipFilePath
-
End If
-
Name Me.ZipFilePath_Temp As Me.ZipFilePath
-
End If
-
-
Exit_ZipAll:
-
Set objShell = Nothing
-
Set objFolder = Nothing
-
Set objFolder2 = Nothing
-
Exit Sub
-
-
Err_ZipAll:
-
Err.Raise Err.Number, Err.Source & " - khZip - ZipAll " & Erl, Err.Description
-
Resume Exit_ZipAll
-
-
End Sub
-
Public Property Get ZipFiles() As khZipFiles
-
Set ZipFiles = mobjZipFile
-
End Property
-
-
Private Sub Class_Terminate()
-
On Error Resume Next
-
Set mobjZipFile = Nothing
-
End Sub
-
-
Public Property Get UnzipFolderPath() As String
-
UnzipFolderPath = mstrUnzipFolderPath
-
End Property
-
-
Public Property Let UnzipFolderPath(strUnzipFolderPathIn As String)
-
mstrUnzipFolderPath = strUnzipFolderPathIn
-
End Property
-
-
Public Property Get ZipFolderPath() As String
-
ZipFolderPath = mstrZipFolderPath
-
End Property
-
-
Public Property Let ZipFolderPath(strZipFolderPathIn As String)
-
mstrZipFolderPath = strZipFolderPathIn
-
End Property
-
-
Friend Property Get ZipFilePath_Temp() As String
-
ZipFilePath_Temp = mstrZipFilePath_Temp
-
End Property
-
-
Friend Property Let ZipFilePath_Temp(strZipFilePath_TempIn As String)
-
mstrZipFilePath_Temp = strZipFilePath_TempIn
-
End Property
-
and the module khZipFile - '---------------------------------------------------------------------------------------
-
' Module : khZipFile
-
' DateTime : 5/18/2007 14:02
-
' Author : Ken Jensen
-
' Purpose : Automate the Windows XP zip functionality
-
'---------------------------------------------------------------------------------------
-
Option Compare Database
-
Option Explicit
-
-
Private Const ERRSOURCE As String = "ZipFile"
-
Private mstrName As String
-
-
Public Property Get Name() As String
-
Name = mstrName
-
End Property
-
-
Public Property Let Name(strNameIn As String)
-
mstrName = strNameIn
-
End Property
-
and module khZipFiles - '---------------------------------------------------------------------------------------
-
' Module : khZipFiles
-
' DateTime : 5/18/2007 14:02
-
' Author : Ken Jensen
-
' Purpose : Automate the Windows XP zip functionality
-
'---------------------------------------------------------------------------------------
-
Option Compare Database
-
Option Explicit
-
-
Private Const ERRSOURCE As String = "ZipFile"
-
Private mcln As Collection
-
-
Public Function Add(strName) As khZipFile
-
-
Dim r As khZipFile
-
-
On Error GoTo Err_Add
-
-
Set r = New khZipFile
-
-
r.Name = strName
-
mcln.Add r, strName
-
-
Set Add = r
-
-
Exit_Add:
-
Set r = Nothing
-
Exit Function
-
-
Err_Add:
-
Err.Raise Err.Number, Err.Source & "-" & ERRSOURCE, Err.Description
-
Resume Exit_Add
-
-
End Function
-
-
Private Sub Class_Initialize()
-
Set mcln = New Collection
-
End Sub
-
-
Public Property Get Count()
-
Count = mcln.Count
-
End Property
-
-
Public Function Remove(strName As String)
-
mcln.Remove strName
-
End Function
-
-
Public Property Get Item(strName) As khZipFile
-
Set Item = mcln(strName)
-
End Property
-
-
Private Sub Class_Terminate()
-
Set mcln = Nothing
-
End Sub
-
-
Friend Function ZipFileString(lngCount As Long) As String
-
ZipFileString = mcln(lngCount).Name
-
End Function
-
-
Hopefully I did this correctly. Let me know if you need anything else.
NeoPa 32,556
Expert Mod 16PB CD Tom:
Hopefully I did this correctly. Let me know if you need anything else.
That looks like a perfect job Tom.
I'm assuming that line #29 of khZip is the one that triggers the error when you run it?
This leaves me somewhat confused. I was under the impression that class _Initialize() procedures were optional. The only conceivable ' error' I can see with your khZipFile code is the absence of such a procedure.
The other weird thing is that Error Trapping, which is a VBA Editor General Option, has to be set to ' Break in Class Module' for anything to trigger for line #29 at all. I guess you have that set correctly, and as there is no further code to hit (No _Initialize() procedure for khZipFile.) the error must fire there. Possibly not so weird if that is the issue, but I'm sure such a problem would have come up with Ken's code earlier if that were the issue.
In short, I'm still not sure about that idea, but it may help to test it out by trying with a dummy procedure in place for that class.
I'm not sure where to start, this is new to me and thou I understand most of the code I'm confused about other, so any help is appreciated.
NeoPa 32,556
Expert Mod 16PB Tom:
I'm not sure where to start, this is new to me
No worries.
You want something like the following to be included in your khZipFile class module : - Private Sub Class_Initialize()
-
'Nothing required in here as it's just a dummy.
-
End Sub
I added that to the khZipfile but still get the same error.
NeoPa 32,556
Expert Mod 16PB
OK Tom. That didn't help it seems. Please feel free to remove that code now as it only told us that wasn't the problem.
I tried to go back to the error message reported, but it seems you haven't given us much information on this. You've given the where (which line it occurs on) but not the what. What (exactly) is the error message (All we know is that you reported it as 'An error automation error' in post #22)?
Line #35 in the khzip module seems to be where I get the error "automation error" if I comment out that line I get back and continues until line #4 then it jumps to the khzip module line 168, 169 170 then goes back and I get an error Object variable or With block variable not set.
I've decided to give up on this, I've wasted to much of your time and to be truthful this has got me so confused I don't know where to continue. I have the zip working with winzip and I'll just let users know that if they don't have winzip loaded they will manually have to zip up the files with what ever zip program they have. Thanks you for all your work, you guys are great.
NeoPa 32,556
Expert Mod 16PB
No worries Tom.
From your earlier post it seems the error was occurring differently from how I understood it from your earlier comment TBF, so tying it down to the actual problem was always going to be difficult.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: A P |
last post by:
I am planning to migrate my exisiting MS Access program that uses yes/no
fields (checkbox). Can ASP identifies checkbox field of ms access? I am
planning to use the same database and use msacess...
|
by: Jim |
last post by:
I am a FoxPro programmer.
What software do I need to program using MS access... I have apps
that are non-web standalone and some web based...
Do you recommend any learning resources?
...
|
by: Dik van der Zwan |
last post by:
I have made a Setup for a ms-access program with the package and
deployment wizard of ms-office 2000. When installing my program with
the Setup, it will make a shortcut to start the program....
|
by: John Harrison |
last post by:
An odd confession; an odd request; but here's the tale....
My company has a few PC systems which we have used for about 7 years
and not updated - we've "made do", and besides, "if it ain't...
|
by: Brian Worth |
last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0
was able to shut down or restart the (windows XP) machine using a series of
API calls. (Getlasterror, GetCurrentProcess,...
|
by: Johnny |
last post by:
I am not an expert but I am trying to develope an access program and have hit the following snag:
Using the queries in one of the fields there is an inserted amount say 3, now if that amount...
|
by: mroks via AccessMonster.com |
last post by:
HELLO GUYS,
anyone could help me on how to connect my MS access program to sql server for
storage of data. i'll be using sql database instead of built in MS Access
database. i have separate...
|
by: Mark |
last post by:
Currently using MS Access 2000 and SQL Server Express. Using the
current DAO OpenRecordset code listed below, however I keep getting
the error message....
3254: ODBC --Cannot lock all records
...
|
by: ken estes |
last post by:
Have an older access program that I loaded to a mass storage device to upload into my laptop (Vista). When I try to initiate the Access program a display comes up saying I need to reformat the older...
|
by: jimatqsi |
last post by:
I have a weird problem at a client site. This has popped up in recent months and I don't know if it is because of an update to my development machine or something updated at the client site.
I'm...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |