Excel Icon

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

How to replace Excel Icon with my own icon?

Please refer to the question send by jpcmaddog. I also have this question to
ask.
Thanks for those who have answered that question but I need more...

Do any experties out there can help us (and also everybody who have the
similar
qestion to ask)?

Microsoft Access able to do this on the Start up menu... by setting the
Applicaton icon to a bitmap file or .ico file. This icon will appear on the
application... but that icon fle must also included together with the access
mdb or mde files, since it is 'link' icon file.
I wonder why this could not be done in Excel? Till now I'm still looking for
the answer!

Looking ahead for any help in this regard.

Thanks in advance,
 
It can be done with API calls. This procedure changes both the icon
in the upper left corner of the 2003 Excel window and the icon on the
Windows XP taskbar.

' Get the handle for a window
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
' Extract an icon from a file
Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" _
(ByVal hInst As Long, ByVal lpszExeFileName As String, _
ByVal nIconIndex As Long) As Long
' Send a Windows message
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, _
ByVal lParam As Long) As Long
' Windows message types
Public Const WM_SETICON = &H80

Sub changeIcon(fName$)
Dim iconFname$, a&, hWnd&, hIcon&
iconFname$ = "c:/folderwithyouriconfile" & "tnt01.ico"
' Get the icon from the source
' 0 = no icons in source, 1 = invalid icon source
hIcon& = ExtractIcon(0, iconFname$, 0)
' set the Excel application window
hWnd = FindWindow("XLMAIN", Application.Caption)
If hWnd& > 0 And hIcon& > 1 Then _
a& = SendMessage(hWnd&, WM_SETICON, False, hIcon&)
' set taskbar icon to small
hWnd& = FindWindow(vbNullString, fName$)
If hWnd& > 0 And hIcon& > 1 Then _
a& = SendMessage(hWnd&, WM_SETICON, False, hIcon&)
End Sub

Call with
changeIcon ActiveWorkbook.Name
or changeIcon Workbooks("yourworkbook").Name

Carl.
 
Hi,

How to replace Excel Icon with my own icon?

Please refer to the question send by jpcmaddog. I also have this questionto
ask.
Thanks for those who have answered that question but I need more...

Do any experties out there can help us (and also everybody who have the
similar
qestion to ask)?

Microsoft Access able to do this on the Start up menu... by setting the
Applicaton icon to a bitmap file or .ico file. This icon will appear on the
application... but that icon fle must also included together with the access
mdb or mde files, since it is 'link' icon file.
I wonder why this could not be done in Excel? Till now I'm still looking for
the answer!

Looking ahead for any help in this regard.

Thanks in advance,

Sorry disturbing you but i was watching your code and i would like to know if i need to put it in a module. Also do i have to copy the whole code or break it in two parts (first one and the Sub one)? Can you help me because i've created a module and pasted all the code there and indicated the location of my icon and the name of it and nothing happens.
 
(e-mail address removed) explained :
Sorry disturbing you but i was watching your code and i would like to know if
i need to put it in a module. Also do i have to copy the whole code or break
it in two parts (first one and the Sub one)? Can you help me because i've
created a module and pasted all the code there and indicated the location of
my icon and the name of it and nothing happens.

Post the code so we know what you're talking about!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
Back
Top