Re : MsgBox temporaire qui ne se ferme pas
on m'a donné une solution sur un autre forum :
Private Sub Workbook_Open()
Select Case Popup("Voulez vous executer la maj ?", 10, "Mise à Jour", _
vbInformation + vbOKCancel + vbDefaultButton2)
Case -1
call maj
Case vbOK
call maj
Case vbCancel
MsgBox "MAJ Canceled"
exit sub
End Select
End Sub
puis dans un module :
Function Popup(ByVal Prompt As String, _
Optional ByVal SecondsToWait As Integer = 0, _
Optional ByVal Title As String = "", _
Optional ByVal Buttons As VbMsgBoxStyle = vbOK) As VbMsgBoxResult
'Show a popup and wait some seconds, returns -1 if the user has not made a selection.
' Solve the problem that wss.Popup doesn't close some times when called directly from VBA
Dim fso As Object 'FileSystemObject
Dim wss As Object 'WshShell
Dim TempFile As String
On Error GoTo ExitPoint
Set fso = CreateObject("Scripting.FileSystemObject")
Set wss = CreateObject("WScript.Shell")
With fso
TempFile = .BuildPath(.GetSpecialFolder(2).Path, .GetTempName & ".vbs")
With .CreateTextFile(TempFile)
.WriteLine "Set wss = CreateObject(""WScript.Shell"")" & vbCrLf & _
"i = wss.Popup(""" & Prompt & """," & SecondsToWait & ",""" & Title & _
"""," & Buttons & ")" & "" & vbCrLf & _
"WScript.Quit i"
.Close
End With
End With
Popup = wss.Run(TempFile, 1, True)
fso.DeleteFile TempFile, True
ExitPoint:
End Function