Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace Microsoft Excel Icon and Title?

Status
Not open for further replies.

Pudsters

Technical User
Mar 16, 2006
151
US
Is it possible to replace the Small Excel Icon in the top left corner of a given Excel application along with the title "Microsoft Excel" and the file name, and replace with a custom icon and title?
I also want to disable the upper right X button so the application can only be closed from a custom close button I created.

Thanks,

Puds
 
so what have you looked at / tried so far ?

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Sorry, I don't know enough vba to even know where to begin but if there is a routine that can do something like that, I would sure like to incorporate it.

Any help would be appreciated.

Puds
 
the title "Microsoft Excel" and the file name
Have a look at the Application.Caption property.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
you could try looking at the application object in the object model to see what properties it has for starters......

in the VBE, press F2 to bring up the object model. Scroll to Application and view tyhe properties...

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Having icon file:
Code:
Private 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
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long

Private Const WM_SETICON = &H80

Sub ChangeExcelIcon()
Dim hIcon As Long
hIcon = ExtractIcon(0, "path&filename", 0)
SendMessage Application.hWnd, WM_SETICON, False, hIcon
End Sub

Sub ResetExcelIcon()
Dim hIcon As Long
hIcon = ExtractIcon(0, Application.Path & "\excel.exe", 0)
SendMessage Application.hWnd, WM_SETICON, False, hIcon
End Sub

combo
 
sorry guys, thanks but none of that helped. Being a newbie to vba, that just wasn't enough information to help.

Combo, I opened up a new workbook, copied your info into a module but just got error messages.
 
You are not so new to VBA that you cannot use the help file and object model - you have posts going back to April of this year so you can't be that green



Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Geoff, Yes I looked at the object model and it showed me a list of a bunch of things that means nothing to me, because I don't understand it! I never gained enough knowledge to self-teach myself VBA, which is why I'm posting!

I was curious if I what I want to accomplish is something other people may have done, and if there is a basic routine that I could copy and paste with minor modifications. If not, fine. Was just looking for a little help.


Puds

 
All you need can be done, but not with basic programming skills, understanding excel's object model would be very helpful.
PH has shown you how to change application title, this can be found in help file. My code could help you to change icon using API, but only for excel xp+, earlier versions miss hWnd property. So in addition to above API calls you would have to use another one to pick application window handler. To prevent application from closing, you could use BeforeClose workbook event procedure, with a switch, description of BeforeClose event again in help file.

combo
 
Thanks Combo, hoping it was something easy, oh well.
 
Pudsters - I notice in another of your threads that you did not have Help installed. I surely hope that situation has beeen corrected. You will not be able to go very far without it.
I never gained enough knowledge to self-teach myself VBA, which is why I'm posting!
This may be a surprise to you then...I am quite willing to bet that the majority of the VBA knowledge here is self-taught.

Self-teaching is pretty much how you ARE going to gain real knowledge.

Well, and also with judicious use, questions, and comments of the the VBA community here.....

Gerry
My paintings and sculpture
 
Hey Fumei, thanks for all of your help, genius. Maybe one day if I learn enough about vba, I can help others as much as you helped me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top