1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
Sub ControleSiOutlookOuvert()
Dim Appli As Object
Dim SessionOutlook, myOlApp
Const Chemin As String = "C:\Program Files\Microsoft Office\office11\OUTLOOK.exe" ---> tu adaptes ce chemin si c'est nécessaire
On Error Resume Next
Set Appli = GetObject(, "Outlook.Application")
'Tester si l'application est ouverte ou non
If Appli Is Nothing Then
MsgBox "Outlook est fermé" '---> Donc ouvre moi une session
SessionOutlook = Shell(Chemin, 1)
Else
MsgBox "Outlook est ouvert" '---> Donc ferme la session existante et ouvre moi une nouvelle session
Set myOlApp = CreateObject("Outlook.Application")
myOlApp.Quit
SessionOutlook = Shell(Chemin, 1)
End If
End Sub |
Partager