Link to home
Start Free TrialLog in
Avatar of Roger
RogerFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to replace Taskbar icon for Excel

Following the following API method:
http://stackoverflow.com/questions/20142765/how-to-change-the-excel-icon-in-taskbar-while-loading
I wrote the following, and called the setTaskBar_Icon procedure from ThisDocument.Workbook_Open():

When I ran the sub with  NewIco = ExtractIcon32(0, myIcoFile, index) with index set between 0 and 8
I got no error reports, and displayed NO change in the classic excel taskbar icon.
Please can you advise?

Option Explicit

Declare Function ExtractIcon32 Lib "shell32.dll" Alias _
"ExtractIconA" (ByVal hInst As Long, _
ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long

Declare Function GetActiveWindow32 Lib "user32" _
Alias "GetActiveWindow" () As Integer

Declare Function SendMessage32 Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Sub setTaskBar_Icon()
    Dim myIcoFile As String
    Dim NewIco

    '~~> Change this to the relevant icon file
    myIcoFile = "D:\aaThink_Build\Icons_Think\Cineris_Document_Manager\Cineris_Doc_Manager_TaskBar_xlIcon.ico"

    NewIco = ExtractIcon32(0, myIcoFile, 0) '<<<<<

    SendMessage32 GetActiveWindow32(), &H80, 1, NewIco
    MsgBox "Hello" 'to check the sub had run fully
End Sub

Source of Cineris_Doc_Manager_TaskBar_xlIcon.ico
.ICO FILE: this file type does not load into EE site, so I changed the extension. If you down load it, please change it back to .ico

Thanks
Kelvin
Cineris-Doc-Manager-TaskBar-xlIcon---Cop
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

It works for me as advertised, with Win7 and XL2007. What versions are you running?
Also, there is only one icon in that ICO file. So any value other that 0 will return nothing.
Avatar of Roger

ASKER

Thanks:
I use excel 2010 and windows 7
When I downloaded the mislabelled ico file and replaced the file name with Cineris-Doc-Manager-TaskBar-xlIcon.ico, and opened in Windows photo viewer I got 8 pages with different icons.

I'm new to icon files, can you tell me: what am I doing wrong?

Kelvin
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roger

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for Kelvin4's comment #a40882032

for the following reason:

Many thanks,
I checked the attached graphics file, by downloading it and changing its name to:
Cineris_Doc_Manager_TaskBar_xlIcon.ico (this name being represented as a string by myIcoFile)

I confirm your observation that NewIco = ExtractIcon32(0, myIcoFile, -1) returns a value of 1

I confirm my observation that when Cineris_Doc_Manager_TaskBar_xlIcon.ico is opened in Windows photo viewer I got 8 pages with different icons.

I have written for guidance to IcoFx (who make the Icon graphics package).

Many thanks for helping me forward.

Kelvin
Avatar of Roger

ASKER

OBJECTION ......... by Kelvin
Total embarrassment!!
I did NOT intend to Claim points for myself!!!!

Please credit  Wayne Taylor (webtubbs) with all 500 points.

Abjectly,
Kelvin
Avatar of Roger

ASKER

Thanks, now I can get my points to you!