ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing the text in the top excel window bar to display your own. (Tip & Question). (https://www.excelbanter.com/excel-programming/297578-changing-text-top-excel-window-bar-display-your-own-tip-question.html)

ironmouse[_2_]

Changing the text in the top excel window bar to display your own. (Tip & Question).
 
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 m
workbook. However, in the top left hand corner I still have the gree
Excel icon. what do I need to use to change the Excel icon picture t
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 no
hopeful.....

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


Michel Pierron[_2_]

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/





All times are GMT +1. The time now is 02:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com