Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessageA Lib "user32" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, _
ByVal lParam As Long) As Long
Private Declare Function ExtractIconA Lib "shell32.dll" _
(ByVal hInst As Long, ByVal lpszExeFileName As String, _
ByVal nIconIndex As Long) As Long
Private Sub Workbook_Activate()
Dim Fichier As String
Dim x As Long
'Chemin et nom du fichier icône à afficher
Fichier = "C:\dossier\nomfichier.ICO"
'Vérifie si le fichier existe
If Dir(Fichier) = "" Then Exit Sub
x = ExtractIconA(0, Fichier, 0)
SendMessageA FindWindow(vbNullString, Application.Caption), _
&H80, False, x
End Sub
Private Sub Workbook_Deactivate()
Dim Fichier As String
Dim x As Long
Fichier = Application.Path & "\excel.exe"
x = ExtractIconA(0, Fichier, 0)
SendMessageA FindWindow(vbNullString, Application.Caption), _
&H80, False, x
End Sub