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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
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.
 

tmanger

Board Regular
Joined
Jul 15, 2002
Messages
101
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.
 

Ian Mac

MrExcel MVP
Joined
Feb 20, 2002
Messages
1,174

ADVERTISEMENT

Nice Dennis :biggrin:
 

Sbirro Cornuto

Board Regular
Joined
Mar 18, 2002
Messages
93
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 . . .
 

mweaver

Board Regular
Joined
Jul 28, 2002
Messages
129
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
 

paddymack

Board Regular
Joined
Oct 24, 2002
Messages
143
Does anyone know how to use Dennis' code to replace the Excel icon directly to the left of The File menu?
 

Forum statistics

Threads
1,148,525
Messages
5,747,194
Members
424,068
Latest member
Salim khamis

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
Top