1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| 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 |
Partager