XL pour MAC fonction maintenant

Delorme

XLDnaute Occasionnel
Bonjour à tous
Passionné de Excel j'ai besoin de votre aide
J'ai cette macro qui permet d'activer la fonction"maintenant" sur une feuille ou elle est installée

Sub decompte()
Application.Calculate
Dim prochain As Double
prochain = Now() + TimeSerial(0, 0, 1)
Application.OnTime prochain, "decompte"
End Sub

Je souhaiterais avoir une macro qui permet de l'arrêter en Vba et non pas en tapant des touches sur le clavier

Merci d'avance

Michel
 

Dranreb

XLDnaute Barbatruc
Bonjour.
Déclarez votre 'prochain' en variable globale pour pouvoir utiliser une Application.OnTime prochain, "decompte", Schedule:=False qui la déplanifiera.
Des idées dans ce classeur.
 

Pièces jointes

  • Progression.xlsm
    210.9 KB · Affichages: 2

Delorme

XLDnaute Occasionnel
Bonjour.
Déclarez votre 'prochain' en variable globale pour pouvoir utiliser une Application.OnTime prochain, "decompte", Schedule:=False qui la déplanifiera.
Des idées dans ce classeur.
Merci de votre réponse, mais je suis un débutant et n'arrive pas à comprendre ces manips
Pourriez vous me taper cette macro dont je me servirais en copier coller
quant au classeur je suis un peu perdu
merci de votre aide
michel
 

Dranreb

XLDnaute Barbatruc
Regardez la procédure AnnulerPlanification du module XPlanificateur de mon classeur, elle comporte un Application.OnTime avec Schedule:=False, et l'heure a bien été conservée puisque bien définie en dehors de toute procédure, vu que c'est même une propriété HeureOT de l'objet Planification, là.
 

Delorme

XLDnaute Occasionnel
Regardez la procédure AnnulerPlanification du module XPlanificateur de mon classeur, elle comporte un Application.OnTime avec Schedule:=False, et l'heure a bien été conservée puisque bien définie en dehors de toute procédure, vu que c'est même une propriété HeureOT de l'objet Planification, là.
ma version d'excel me fait des difficultés pour ouvrir votre classeur
 

Dranreb

XLDnaute Barbatruc
Ah oui, c'est sur MAC, je n'avais pas vu. Je ne réponds généralement pas aux demandes pour MAC.
Je reproduit le code du module XPlanificateur :
VB:
Rem. Module de servive effecteur de tâches des objets Planification.
'    NE PAS UTILISER EN PROGRAMMATION APPLICATIVE.
Option Explicit
Private TPlanifications() As Planification, Idt As Long
Public Sub DéplanifierTout()
   Dim P As Long, M As Long
   On Error Resume Next: M = UBound(TPlanifications): If Err Then Exit Sub
   On Error GoTo 0
   For P = 1 To M: Idt = Idt Mod M + 1
      If Not TPlanifications(Idt) Is Nothing Then TPlanifications(Idt).Annuler
      Set TPlanifications(Idt) = Nothing: Next P
   End Sub
Public Function IdtPlanificationLancée(ByVal Source As Planification) As Long
   Dim P As Long, M As Long
   On Error Resume Next: M = UBound(TPlanifications): If Err Then ReDim TPlanifications(1 To 1): M = 1
   On Error GoTo 0
   For P = 1 To M: Idt = Idt Mod M + 1
      If TPlanifications(Idt) Is Nothing Then Exit For
      Next P
   If P > M Then ReDim Preserve TPlanifications(1 To P): Idt = P
   Set TPlanifications(Idt) = Source
   Application.OnTime Source.HeureOT, "'XPlanificateur.OnTimeJoue " & Idt & "'"
   IdtPlanificationLancée = Idt
   End Function
Public Sub AnnulerPlanification(ByVal Idt As Long)
   On Error Resume Next
   Application.OnTime TPlanifications(Idt).HeureOT, "'XPlanificateur.OnTimeJoue " & Idt & "'", Schedule:=False
   Set TPlanifications(Idt) = Nothing
   End Sub
Private Sub OnTimeJoue(ByVal Idt As Long)
   On Error Resume Next
   TPlanifications(Idt).Actionner
   Set TPlanifications(Idt) = Nothing
   End Sub
 

Delorme

XLDnaute Occasionnel
Ah oui, c'est sur MAC, je n'avais pas vu. Je ne réponds généralement pas aux demandes pour MAC.
Je reproduit le code du module XPlanificateur :
VB:
Rem. Module de servive effecteur de tâches des objets Planification.
'    NE PAS UTILISER EN PROGRAMMATION APPLICATIVE.
Option Explicit
Private TPlanifications() As Planification, Idt As Long
Public Sub DéplanifierTout()
   Dim P As Long, M As Long
   On Error Resume Next: M = UBound(TPlanifications): If Err Then Exit Sub
   On Error GoTo 0
   For P = 1 To M: Idt = Idt Mod M + 1
      If Not TPlanifications(Idt) Is Nothing Then TPlanifications(Idt).Annuler
      Set TPlanifications(Idt) = Nothing: Next P
   End Sub
Public Function IdtPlanificationLancée(ByVal Source As Planification) As Long
   Dim P As Long, M As Long
   On Error Resume Next: M = UBound(TPlanifications): If Err Then ReDim TPlanifications(1 To 1): M = 1
   On Error GoTo 0
   For P = 1 To M: Idt = Idt Mod M + 1
      If TPlanifications(Idt) Is Nothing Then Exit For
      Next P
   If P > M Then ReDim Preserve TPlanifications(1 To P): Idt = P
   Set TPlanifications(Idt) = Source
   Application.OnTime Source.HeureOT, "'XPlanificateur.OnTimeJoue " & Idt & "'"
   IdtPlanificationLancée = Idt
   End Function
Public Sub AnnulerPlanification(ByVal Idt As Long)
   On Error Resume Next
   Application.OnTime TPlanifications(Idt).HeureOT, "'XPlanificateur.OnTimeJoue " & Idt & "'", Schedule:=False
   Set TPlanifications(Idt) = Nothing
   End Sub
Private Sub OnTimeJoue(ByVal Idt As Long)
   On Error Resume Next
   TPlanifications(Idt).Actionner
   Set TPlanifications(Idt) = Nothing
   End Sub
merci mais sans vous importuner pourriez vous me taper simplement la macro qui m'interresse
je n'ai sans doute pas besoin de tout ça
juste les quelques lignes de vba pouvant me servir en une commande stop
 

Dranreb

XLDnaute Barbatruc
VB:
Option Explicit
Private HeureOT As Date
Sub Decompte()
   Application.Calculate
   HeureOT = Now() + TimeSerial(0, 0, 1)
   Application.OnTime HeureOT, "Decompte"
   End Sub
Sub StopperDecompte()
   If HeureOT Then
      Application.OnTime HeureOT, "Decompte", Schedule:=False
      HeureOT = 0: End If
   End Sub
 

Delorme

XLDnaute Occasionnel
VB:
Option Explicit
Private HeureOT As Date
Sub Decompte()
   Application.Calculate
   HeureOT = Now() + TimeSerial(0, 0, 1)
   Application.OnTime HeureOT, "Decompte"
   End Sub
Sub StopperDecompte()
   If HeureOT Then
      Application.OnTime HeureOT, "Decompte", Schedule:=False
      HeureOT = 0: End If
   End Sub
merci beaucoup
dernière ligne
vous me proposez une macro décompte pour activer et une pour stopper ce qui remplace ma première macro que je vous ai soumise est ce bien cela?
mais dois je taper les 2 premières lignes code et private ?
 

Discussions similaires

Réponses
7
Affichages
485