Excel Icon
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.
On May 7, 12:41 am, Badrul wrote:
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,
|