Here's my problem, I have in my application a backup procedure that creates .txt files for each table. I use the docmd.transfertext to export the data. This creates a number of .txt files. I decided to zip those files up so that I only have a .zip file instead of many .txt files. I'm using Ken Jensen zip module, there are four modules basZip, khZip, khZipfile and khZipfiles this is working fine on 95% of my users however there a a couple that have a problem. Everything goes fine until the very last and then they get an error message that the zip file is empty. Now here comes the funny part. I've run the program on there computer and have stopped the code so I could step it through, when I do the step through it works fine but when I run it straight through I get the error. When I get the error the zip file isn't created, when I step through the code it works and I get the zip file.
I'm wondering if anyone has seen this type of problem, or maybe there is a better way of doing the zipping up instead of using Ken Jensens zip modules.
Thanks for any advise and help
Hi Tom.
I don't know your Zipping program so all I can say at this point is that Shell() , and ShellWait() , are both calls that allow you to run programs in the same way as you might from a Command Prompt. That means a BAT or CMD file can be executed from there. Do you have, or can you create, such a file to execute the task you need to execute?
9 1865 NeoPa 32,556
Expert Mod 16PB
It sounds like you may be suffering from some sort of race condition. Something that you rely on to be ready at such and such a point isn't.
Usually VBA is single-threaded so it's hard to guess what that might be, but adding DoEvents() function calls between files may well help.
Good luck Tom.
Is that all there is to the command is DoEvents().
NeoPa 32,556
Expert Mod 16PB CD Tom:
Is that all there is to the command is DoEvents().
I've no idea what you're trying to ask.
Butting in, Tom is asking if there are any parameters with DoEvents() and the answer is no (and you don't even need the brackets).
Phil
I guess I figured that out, but I've tried everything to get this to work, by putting the DoEvents in many different places, But nothing seems to work. I can't seem to find where the error message is coming from. The following code is where I think the error is happening but like I said when I step through the process it works just fine. - 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
-
Any ideas where to slow this down.
NeoPa 32,556
Expert Mod 16PB
Hi Tom.
This is the first time we've seen your code, which is strange considering this is what you're asking for help with.
My first comment would be that using scripting to handle this is unnecessary. There is a Shell() function available in VBA that allows you to run Command Line commands. I have also written, for situations just such as this where it's important to ensure the process is completed before allowing the VBA to continue, a version called ShellWait().
My second comment would be that you have inserted the DoEvents() calls into your code intelligently so if that isn't working then that doesn't seem to be the solution.
We all have our own preferred ways of doing things and I prefer to use standard VBA calls where they're available rather than scripting objects.
Thanks for your response. Seeing this is the first time I've tried to do anything like zipping up files I didn't have any idea what to do. I looked and found what I thought was the best answer, but I guess I'm finding out it wasn't. I'm not sure VBA calls to use, Shell() and shellWait() sound like a good start. Where can I find more information on how to use these with my zipping problem. I appreciate all your help and information. I keep learning things from you guys. Thanks lots.
NeoPa 32,556
Expert Mod 16PB
Hi Tom.
I don't know your Zipping program so all I can say at this point is that Shell() , and ShellWait() , are both calls that allow you to run programs in the same way as you might from a Command Prompt. That means a BAT or CMD file can be executed from there. Do you have, or can you create, such a file to execute the task you need to execute?
Ok, I've been trying different ways to do this zipping up and here's the code I've found to work. - Dim objFSO As Object, objZip As Object, objShell As Object
-
Dim objFolder As Object, objFile As Object
-
Dim sngStart As Single
-
Dim strPath As String, strZip As String
-
strPath = FolderName
-
-
strZip = strbkfoldername 'Output zip file
-
-
Set objFSO = CreateObject("Scripting.FileSystemObject")
-
Set objZip = objFSO.CreateTextFile(strZip)
-
objZip.WriteLine Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
-
objZip.Close
-
-
Set objShell = CreateObject("Shell.Application")
-
Set objFolder = objFSO.GetFolder(strPath)
-
DoCmd.Hourglass True
-
'loop through files - adding them to the
-
For Each objFile In objFolder.Files
-
If objFile <> strZip Then
-
objShell.Namespace("" & strZip).CopyHere objFile.Path
-
'objShell.Namespace("" & strZip).MoveHere objFile.Path
-
sngStart = Timer
-
Do While Timer < sngStart + 1
-
DoEvents
-
Loop
-
End If
-
Next
-
DoCmd.Hourglass False
-
This works great when I select a disk drive. But if I select a jump drive I keep getting this message everytime it gets a file to zip. "Please insert the last disk of the Multi-volume set and click ok to continue"
There are 54 files that are being .copyhere so you end up clicking the OK 54 times. Can you see any way to eliminate this message?
Thanks again for any help
I've tried the .movehere also and get the same message.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joseph S. |
last post by:
Hi,
(1) I have about 8-9 .php files which are far from complex. I first
used GET in all of them. Worked fine. Then I changed all method="get"
to method="post" and $_GET to $_POST with...
|
by: James Bright |
last post by:
I have set up custom Intellisense for our project. (In a nutshell, we will
have ASP.NET controls based on many of the statndard WebControls, but with a
few extensions that we will be adding). I've...
|
by: Suri |
last post by:
hi im trying to run this simple program. any help shall be appreciated
..pls see error message.
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
double pic;
pic= 4.0 *...
|
by: arthernan |
last post by:
Let's say I have this class.
public class oompa_loompa: halfling
{
public var automobile;
}
public first_oompa_loompa oompa_loompa = new oompa_loompa();
|
by: Michael Hesse |
last post by:
Hi,
I am trying to go from VB to ASP. The following code works perfectly in VB.
Dim cn as New SqlConnection
Dim sConnect as String = "workstation id=VECTRA\mh;data
source=VECTRA;Initial...
|
by: vishal |
last post by:
I am trying to send a mail using the system.web.mail namespace where I
provide the required code and send the mail.
I found that It was sending mail while using BSNL Broadband and was
unable to do...
|
by: Steve Jorgensen |
last post by:
Generally, it is the case that space characters in the names of things
can cause difficulties, and removing the spaces can make things work
more smoothly, but I recently found a reverse case.
I...
|
by: Markus Svilans |
last post by:
Hi,
I have a weird problem in a virtual method. The original method code
raises an access violation when it is run. The solution to the problem
is to declare a dummy integer inside the virtual...
|
by: aquablade |
last post by:
I have an Oracle 10g R2 database where my ERP transactions reside. I'm using MS Access to grant access to my power users where I use MS Access' Link Tables to provide direct access.
I noticed that...
|
by: tiger3p |
last post by:
Hello..
I'm hoping someone could help me out with this access problem..
I want to create a table that draws information from an already populated table (tblEmployee). This new table will...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |