View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Michel Pierron[_2_] Michel Pierron[_2_] is offline
external usenet poster
 
Posts: 63
Default Changing the text in the top excel window bar to display your own. (Tip & Question).

Hi ironmouse,
In ThisWorkbook module:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" _
(ByVal hInst As Long, ByVal lpszExeFileName As String _
, ByVal nIconIndex As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer _
, ByVal lParam As Any) As Long

Private Sub Workbook_Open()
AppSetIcon False
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
AppSetIcon True
End Sub

Private Sub AppSetIcon(Optional Restore As Boolean = False)
Dim hwnd As Long, hIcon As Long
If Not Restore Then
If Dir(ThisWorkbook.Path & "\MyIcon.ico") = "" Then Exit Sub
hIcon = ExtractIcon(0, ThisWorkbook.Path & "\MyIcon.ico", 0)
End If
hwnd = FindWindow(vbNullString, Application.Caption)
SendMessage hwnd, &H80, 0, hIcon ' Small Icon
SendMessage hwnd, &H80, 1, hIcon ' Big Icon
End Sub

Regards,
MP

"ironmouse " a écrit dans le message de
...
In VBA I am using

Application.Caption = "my own text"
ActiveWindow.Caption = "my own text"

to change the text in the Excel Window header at the top of my
workbook. However, in the top left hand corner I still have the green
Excel icon. what do I need to use to change the Excel icon picture to
my own, or to get rid of it completely?
Is it possible?
Tnx, ironmouse.

pls note that this is the second time I have posted this question.
Last week I posted it and had 15 views but no replies. I'm not
hopeful......


---
Message posted from http://www.ExcelForum.com/