Bonjour à tous,

J'ai créé une macro qui fait les opérations suivantes :
- Création d'un fichier Excel à partir d'un fichier texte
- Copie d'un fichier d'archive Zip d'un lecteur reseau vers le disque D:
- Ajout du fichier Excel dans le fichier Zip
- Copie du fichier Zip sur le lecteur Reseau
- Suppression du fichier excel et du fichier texte

La macro me signale une erreur lorsque je veux ajouter le fichier excel dans l'archive.

Si je mets des points d'arrêts dans l'execution je ne rencontre pas de problème...

En fait l'erreur est provoqué car au moment de zipper le fichier excel celui a déjà été supprimé par la maccro... Car le lancement du zip est trop lent...

Donc je voulais savoir comment ajouter une pause dans l'éxécution de ma macro en évitant d'utiliser la méthode Application.wat (now + "00:00:10")

Voici le code impacté...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
Dim zippeur As String
Dim fichierAZipper As String
Dim archiveZip As String
Dim copyArchiveZip As String
 
zippeur = METHODE_ZIPPEUR
fichierAZipper = VG_Path_TotoTxt & "\" & Format(DateTraitementPourSaveFichier, "yyyymmdd") & _
                                        "_Toto.xls"
archiveZip = VG_Path_IndicGusoTxt & "\" & "GUSO " & Format(DateTraitementPourSaveFichier, "yyyy") & _
                                        " " & Format(DateTraitementPourSaveFichier, "mm") & _
                                        " " & Format(DateTraitementPourSaveFichier, "mmmm") & _
                                        " (xls).zip"
 
copyArchiveZip = RACINE_D & "\" & "GUSO " & Format(DateTraitementPourSaveFichier, "yyyy") & _
                                        " " & Format(DateTraitementPourSaveFichier, "mm") & _
                                        " " & Format(DateTraitementPourSaveFichier, "mmmm") & _
                                        " (xls).zip"
 
FileCopy archiveZip, copyArchiveZip
DoEvents
 
Shell (zippeur & Chr(34) & copyArchiveZip & Chr(34) & " " & Chr(34) & fichierAZipper & Chr(34))     ' ne rendra la main qu'une fois terminé
DoEvents
 
FileCopy copyArchiveZip, archiveZip
DoEvents
 
'   Suppression du fichier IndicGuso.txt et le fichier XLS
'   ======================================================
Kill (VG_Path_TotoTxt & "\" & VG_Nom_TotoTxt)
'   Ajouté par PKI
'=================
Kill (VG_Path_TotoTxt & "\" & Format(DateTraitementPourSaveFichier, "yyyymmdd") & _
        "_Toto.xls")
Kill (copyArchiveZip)