S
Sylvain
Guest
Bonjour,
Il y a t'il un moyen pour mettre un délais entre deux excution de commande vba ?
je m'explique:
J'ai une macro qui m'enregistre mes données dans une base de données puis j'en ai une autre qui efface les données à l'écran (elle me laisse les zones à remplir vide). Quand j'associe les deux (enregistrement puis effacement), les commandes d'effacement ne laisse pas le temps à l'enregistrement de ce faire.
J'ai essayé ces commandes entre les deux mais ca m'arrete l'enregistrement.
nvlleHeure = Hour(Now())
nvlleMinute = Minute(Now())
nvlleSeconde = Second(Now()) + 5
waitTime = TimeSerial(nvlleHeure, nvlleMinute, nvlleSeconde)
Application.Wait waitTime
Mes commandes pour enregistrer sont la suivante :
Sub enreg_auto()
SendKeys ("^s")
SendKeys "{tab}"
SendKeys "{tab}"
SendKeys "{down}"
SendKeys "{tab}"
SendKeys "~"
End Sub
Mes commandes pour effacer sont la suivante :
Sub Nouvelle_Fiche()
'
' Macro2 Macro
' Macro enregistrée le 12/08/02 par PIGEON SYLVAIN
'
'
Rows("7:129").Select
ActiveWindow.SmallScroll Down:=-113
Selection.ClearContents
Range("C88").Select
Sheets("Table").Select
ActiveWindow.SmallScroll Down:=-63
Range("B9").Select
ActiveCell.FormulaR1C1 = "0"
Range("B16").Select
ActiveCell.FormulaR1C1 = "0"
Range("G9").Select
ActiveCell.FormulaR1C1 = "0"
Range("G16").Select
ActiveCell.FormulaR1C1 = "0"
Range("G23").Select
ActiveCell.FormulaR1C1 = "0"
Range("G2").Select
ActiveCell.FormulaR1C1 = "0"
Range("B2").Select
ActiveCell.FormulaR1C1 = "0"
Range("B35").Select
ActiveCell.FormulaR1C1 = "0"
Range("G35").Select
ActiveCell.FormulaR1C1 = "0"
Range("B42").Select
ActiveCell.FormulaR1C1 = "0"
Range("G42").Select
ActiveCell.FormulaR1C1 = "0"
Range("G52").Select
ActiveCell.FormulaR1C1 = "0"
Range("B52").Select
ActiveCell.FormulaR1C1 = "0"
Range("B54").Select
ActiveCell.FormulaR1C1 = ""
Range("B55").Select
ActiveCell.FormulaR1C1 = "0"
Range("B62").Select
ActiveCell.FormulaR1C1 = "0"
Range("B65").Select
ActiveCell.FormulaR1C1 = "0"
Range("G62").Select
ActiveCell.FormulaR1C1 = "0"
Range("G65").Select
ActiveCell.FormulaR1C1 = "0"
Range("G73").Select
ActiveCell.FormulaR1C1 = "0"
Range("B73").Select
ActiveCell.FormulaR1C1 = "0"
Range("B79").Select
ActiveCell.FormulaR1C1 = "0"
Range("B86").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B87").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B88").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B89").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B90").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G86").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G87").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G88").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G89").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G90").Select
ActiveCell.FormulaR1C1 = "FALSE"
Sheets("Fiche de saisie").Select
End Sub
Merci pour votre aide.
Sylvain
Il y a t'il un moyen pour mettre un délais entre deux excution de commande vba ?
je m'explique:
J'ai une macro qui m'enregistre mes données dans une base de données puis j'en ai une autre qui efface les données à l'écran (elle me laisse les zones à remplir vide). Quand j'associe les deux (enregistrement puis effacement), les commandes d'effacement ne laisse pas le temps à l'enregistrement de ce faire.
J'ai essayé ces commandes entre les deux mais ca m'arrete l'enregistrement.
nvlleHeure = Hour(Now())
nvlleMinute = Minute(Now())
nvlleSeconde = Second(Now()) + 5
waitTime = TimeSerial(nvlleHeure, nvlleMinute, nvlleSeconde)
Application.Wait waitTime
Mes commandes pour enregistrer sont la suivante :
Sub enreg_auto()
SendKeys ("^s")
SendKeys "{tab}"
SendKeys "{tab}"
SendKeys "{down}"
SendKeys "{tab}"
SendKeys "~"
End Sub
Mes commandes pour effacer sont la suivante :
Sub Nouvelle_Fiche()
'
' Macro2 Macro
' Macro enregistrée le 12/08/02 par PIGEON SYLVAIN
'
'
Rows("7:129").Select
ActiveWindow.SmallScroll Down:=-113
Selection.ClearContents
Range("C88").Select
Sheets("Table").Select
ActiveWindow.SmallScroll Down:=-63
Range("B9").Select
ActiveCell.FormulaR1C1 = "0"
Range("B16").Select
ActiveCell.FormulaR1C1 = "0"
Range("G9").Select
ActiveCell.FormulaR1C1 = "0"
Range("G16").Select
ActiveCell.FormulaR1C1 = "0"
Range("G23").Select
ActiveCell.FormulaR1C1 = "0"
Range("G2").Select
ActiveCell.FormulaR1C1 = "0"
Range("B2").Select
ActiveCell.FormulaR1C1 = "0"
Range("B35").Select
ActiveCell.FormulaR1C1 = "0"
Range("G35").Select
ActiveCell.FormulaR1C1 = "0"
Range("B42").Select
ActiveCell.FormulaR1C1 = "0"
Range("G42").Select
ActiveCell.FormulaR1C1 = "0"
Range("G52").Select
ActiveCell.FormulaR1C1 = "0"
Range("B52").Select
ActiveCell.FormulaR1C1 = "0"
Range("B54").Select
ActiveCell.FormulaR1C1 = ""
Range("B55").Select
ActiveCell.FormulaR1C1 = "0"
Range("B62").Select
ActiveCell.FormulaR1C1 = "0"
Range("B65").Select
ActiveCell.FormulaR1C1 = "0"
Range("G62").Select
ActiveCell.FormulaR1C1 = "0"
Range("G65").Select
ActiveCell.FormulaR1C1 = "0"
Range("G73").Select
ActiveCell.FormulaR1C1 = "0"
Range("B73").Select
ActiveCell.FormulaR1C1 = "0"
Range("B79").Select
ActiveCell.FormulaR1C1 = "0"
Range("B86").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B87").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B88").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B89").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B90").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G86").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G87").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G88").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G89").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G90").Select
ActiveCell.FormulaR1C1 = "FALSE"
Sheets("Fiche de saisie").Select
End Sub
Merci pour votre aide.
Sylvain