Application.wait

J

jon

Can anyone tell me what library reference I have to install to use
application.wait in my VBA in access 97 ?

Thanks

Jon
 
J

jon

Hi Douglas,
I'm trying to Zip all the files in a folder, and then attach them to an
email, but if there are too many, the zipping takes too long, and it all
goes tits up.

To Zip up the files I'm using code I found at
http://www.rondebruin.nl/windowsxpzip.htm#Code

The code is below, any ideas how I can achieve the same in access ?


Sub Zip_All_Files_in_Folder_Browse()
Dim FileNameZip, FolderName, oFolder
Dim strDate As String, DefPath As String
Dim oApp As Object

DefPath = Application.DefaultFilePath
If Right(DefPath, 1) <> "\" Then
DefPath = DefPath & "\"
End If

strDate = Format(Now, " dd-mmm-yy h-mm-ss")
FileNameZip = DefPath & "MyFilesZip " & strDate & ".zip"

Set oApp = CreateObject("Shell.Application")

'Browse to the folder
Set oFolder = oApp.BrowseForFolder(0, "Select folder to Zip", 512)
If Not oFolder Is Nothing Then
'Create empty Zip File
NewZip (FileNameZip)

FolderName = oFolder.Self.Path
If Right(FolderName, 1) <> "\" Then
FolderName = FolderName & "\"
End If

'Copy the files to the compressed folder
oApp.Namespace(FileNameZip).CopyHere
oApp.Namespace(FolderName).items

'Keep script waiting until Compressing is done
On Error Resume Next
Do Until oApp.Namespace(FileNameZip).items.Count =
oApp.Namespace(FolderName).items.Count
Application.Wait (Now + TimeValue("0:00:01"))
Loop

MsgBox "You find the zipfile here: " & FileNameZip
On Error GoTo 0

Set oApp = Nothing
Set oFolder = Nothing
End If
End Sub

Thanks

Jon
 
R

Ron de Bruin

Hi jon

You can use the Sleep api in Access

Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)

In the code

Sleep 3000 ' 3 seconds
 
J

jon

Hi Ron,
Thanks for the reply.

I had seen that and I tried to use it but I couldn't figure out how to use
it correctly.

If this is the part of the code I am replacing
'Keep script waiting until Compressing is done
On Error Resume Next
Do Until oApp.Namespace(FileNameZip).items.Count =
oApp.Namespace(FolderName).items.Count
Application.Wait (Now + TimeValue("0:00:01"))
Loop


What should I replace it with ?

Jon
 
R

Ron de Bruin

Hi Jon

At the top of the module (not in the macro)

Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)

Replace
Application.Wait (Now + TimeValue("0:00:01"))

For

Sleep 1000
 
T

Tony Toews [MVP]

jon said:
I'm trying to Zip all the files in a folder, and then attach them to an
email, but if there are too many, the zipping takes too long, and it all
goes tits up.

Use the Info Zip dlls instead. There are links to working code found
at Compression DLLs, OCXs, etc
http://www.granite.ab.ca/access/compression.htm

Then you won't need to wait for the external process to complete. And
you'll be able to do better error handling.

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/
 
Top