Bonjour à tous,
J'utilise le code suivant pour activer un Timer sur une Msgbox, et cela fonctionne très bien :
Private Declare PtrSafe Function MsgBoxTimeout _
Lib "user32" _
Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As LongPtr, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal wType As VbMsgBoxStyle, _
ByVal wlange As Long, _
ByVal dwTimeout As Long) _
As Long
Sub btnMsgbox()
Call MsgBoxTimeout(0, "La tâche est terminée. " & vbLf & "Souhaitez vous fermer le fichier ?", "Fin de tâche", vbYesNoCancel+ vbInformation, 0, 10000)
End Sub
Je souhaiterai transformer cette Msgbox en vbYesNoCancel avec des conditions en fonction de la réponse du type :
If MsgBoxTimeout = vbYes Then
Activeworkbook.close savechanges:=True
ElseIf MsgBoxTimeout = vbNo Then
Activeworkbook.save
ElseIf MsgBoxTimeout = vbCancel Then
Nothing
else
Activeworkbook.close savechanges:=True
End if
Je butte sur ce point, j'apprécierai vos contributions.
D'avance merci.
Cordialement
Patrick