my add-in sets the application icon to an icon of my choosing when it runs, as per the following standard code. i have two questions:
1. the icon change works for the application in the top-left part of the application window and for the small window which appears when the Excel taskbar button is pressed. but it doesn't change the icon on the taskbar itself - can this be changed, please?
2. how can i change the icon back to its original state (the standard Excel icon)? presumably the standard windows icons are all stored in a particular folder and i can just point to this?
many thanks
gusset
Sub SetApplicationIcon(strIconPath As String)
Dim hWnd As Long
Dim hIcon As Long
'get the handle of the Excel window
hWnd = FindWindow("XLMAIN", ActiveWorkbook.Application.Caption)
'get the icon from the source file
hIcon = ExtractIcon(0, strIconPath, 0)
'1 means invalid icon source, 0 means no icons in source
If hIcon >= 1 Then
'set the 32x32 and 16x16 icons
SendMessage hWnd, WM_SetIcon, True, hIcon
SendMessage hWnd, WM_SetIcon, False, hIcon
End If
End Sub
1. the icon change works for the application in the top-left part of the application window and for the small window which appears when the Excel taskbar button is pressed. but it doesn't change the icon on the taskbar itself - can this be changed, please?
2. how can i change the icon back to its original state (the standard Excel icon)? presumably the standard windows icons are all stored in a particular folder and i can just point to this?
many thanks
gusset
Sub SetApplicationIcon(strIconPath As String)
Dim hWnd As Long
Dim hIcon As Long
'get the handle of the Excel window
hWnd = FindWindow("XLMAIN", ActiveWorkbook.Application.Caption)
'get the icon from the source file
hIcon = ExtractIcon(0, strIconPath, 0)
'1 means invalid icon source, 0 means no icons in source
If hIcon >= 1 Then
'set the 32x32 and 16x16 icons
SendMessage hWnd, WM_SetIcon, True, hIcon
SendMessage hWnd, WM_SetIcon, False, hIcon
End If
End Sub