Changing the Excel Icon.....

UKPhil

New Member
Joined
Jul 25, 2002
Messages
49
Hi Guys;
I Have the following code which enables you to change the Excel Icon to the notepad icon. What I want to do Is change to a completely new Icon I have designed myself, however judging by the way the VBA 'extracts' the icon from notepad I'm presuming that I will only be able to use Icon's from other windows programs? could someone confirm if this is correct? and If I want to use my own Icon am I barking up the wrong tree?

code is:
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

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

Sub ChangeXLIcon()
Dim h32NewIcon As Long
Dim h32WndXLMAIN As Long
h32NewIcon = ExtractIcon32(0, "Notepad.exe", 0)
h32WndXLMAIN = GetActiveWindow32()
SendMessage32 h32WndXLMAIN, &H80, 1, h32NewIcon 'Icon big
SendMessage32 h32WndXLMAIN, &H80, 0, h32NewIcon 'Icon small
End Sub


(Apologies, original source Unknown)

thanks-in-advance guys

UK P
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
and have you tried changing:

ExtractIcon32(0, "Notepad.exe", 0)

to this ?

ExtractIcon32(0, "MyIco.ico", 0)

The first number i don't know what it is, but the secon 0, should indicate the Index of the icon you want to extract.
 
Upvote 0
I have seen and tried this code as well. It is listed on John Walkenbach's site/newsletters. Changing the notepad.exe file to an *.ico file does not work, though, as said above, one can change this to any Windows *.exe (eg. winword.exe) and it will work.

Perhaps someone has another solution?

Thanks.

Tom.
 
Upvote 0
Very impressive Dennis, very impressive indeed!
Anybody got an idea how to use .ani file instead of an .ico file? And use it the way that the animation works?
This would be very cool, but I don´t know if it would possible as well . . .
 
Upvote 0
Dennis,

Wow! Really Clever. I like the way that works.

If I have two workbooks open in the same excel session I can make the titlebar icon toggle between Excel and custom, but I cannot make the active window icon toggle..... Any Ideas?


mweaver
 
Upvote 0
Does anyone know how to use Dennis' code to replace the Excel icon directly to the left of The File menu?
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top