Sub OuvreOutlook()
Dim oOutlook As Object
Dim déjàOuvert As Boolean
On Error Resume Next
'Voir si outlook est déjà ouvert
Set oOutlook = GetObject(, "Outlook.application")
déjàOuvert = Not oOutlook Is Nothing
's'il ne l'est pas, tenter de l'ouvrir par createObject
If Not déjàOuvert Then
Set oOutlook = CreateObject("Outlook.application")
If oOutlook Is Nothing Then
MsgBox "impossible d'ouvrir Outlook", vbExclamation, "Ouverture outlook"
Exit Sub
End If
End If
On Error GoTo 0
'MON CODE ICI
'Fin macro
'Si outlook n'était pas ouvert, au début alors le fermer
If Not déjàOuvert Then oOutlook.Quit
Set oOutlook = Nothing 'libérer la variable correctement
End Sub