'*****************************************************************************************************
' ___ _ _______ __ _ ____ _ _ _______ ___ _ _ _ ___ _ _.
' // \\ /\\ // // \\ // // // // // // \\ // // // // \\ //| //
' //___// //__\ // //__// // // //__// // // // // // // // // // | //
' // // \\ // // \\ // // // \\ // // // // // // // // // | //
'// // // // // // // //___ // \\ // \\__// //__// //___ \\__// // |//
'****************************************************************************************************
'fonction pour changer l'icon de excel
'patricktoulon
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As LongPtr) As Long
#Else
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
#End If
Const WM_SETICON As Long = &H80
Const ICON_SMALL As Long = 0
Const ICON_BIG As Long = 1
#If VBA7 Then
Sub XlMainIconSwitch(Optional ByVal hIcon As LongPtr = 0&)
Dim hWnd As LongPtr
#Else
Sub XlMainIconSwitch(Optional ByVal hIcon As Long = 0&)
Dim hWnd As Long
#End If
Dim Res As Long
hWnd = FindWindow("XLMAIN", Application.Caption)
'Res = SendMessage(hWnd, WM_SETICON, ICON_SMALL, ByVal hIcon)
Res = SendMessage(hWnd, WM_SETICON, ICON_BIG, ByVal hIcon)
Res = DrawMenuBar(hWnd)
End Sub