changing the application name in the title bar

  • Thread starter Thread starter Paul James
  • Start date Start date
P

Paul James

I once read there was a way to change the name of an application as it
appears in the Excel title bar. That is, to replace the "Microsoft Excel -
filename.xls" with whatever name you want to use.

I tried using "Application.Name = "my application name" but I got the error
message "Can't assign to read-only property." Is there a way to accomplish
this?

Thanks in advance

Paul
 
Paul

Vasant gave you the code for this but must be noted that this is not a
permanent change and has to be re-done each time you close out and re-start
Excel.

Place the code into a Thisworkbook Workbook_Open Sub or a General Module
Auto_Open Sub.

Gord Dibben Excel MVP
 
Application.Caption = "MyNewCaption"

So that's how you do it!

Thanks (again), Vasant.

Question: I notice that when I do this, it not only puts "MyNewCaption" in
the title bar, but it also adds the filename to the string I assign to the
Caption property. In other words, it places "MyNewCaption - MyFilename.xls"
in the title bar. Is there a parameter I can add to the property assignment
that would remove the filename from the caption, and only display the
assigned string?
 
Thanks, Gord. That's good information to have.

I'll put it in the Auto_Open sub.


Another question:

I only need the custom caption while a particular workbook is open. If I
want to reset the caption when that workbook closes, can I do that by simply
putting

Application.Caption = "Microsoft Excel"

in the Auto_Close procedure?

Thanks
 
I think that this is actually showing the activeworkbook's name since you have
the workbook's window maximized. I think it's excel's way of helping you.

(If you restore the workbook's window (not the application's window), to less
than maximized, you'll see that the appliation caption doesn't show the
workbook's name.
 
application.caption = ""

would reset it.



Paul said:
Thanks, Gord. That's good information to have.

I'll put it in the Auto_Open sub.

Another question:

I only need the custom caption while a particular workbook is open. If I
want to reset the caption when that workbook closes, can I do that by simply
putting

Application.Caption = "Microsoft Excel"

in the Auto_Close procedure?

Thanks
 
Or add the activewindow.caption

Sub bothcaptions()
Application.Caption = "MyApplication"
ActiveWindow.Caption = ""
End Sub

Gord
 
Paul

Yes, you can reset it in the Auto_close code.

If you leave it blank, it will default to "Microsoft Excel"

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.Caption = ""
End Sub

Gord Dibben Excel MVP
 
Hi Paul:

Here's a complete set of routines that I think will do what you want:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.Caption = ""
End Sub

Private Sub Workbook_Open()
Application.Caption = "MyNewCaption"
With ActiveWindow
If .WindowState = xlMaximized Then
.Caption = ""
Else
.Caption = Name
End If
End With
End Sub

Private Sub Workbook_WindowResize(ByVal Wn As Window)
With Wn
If .WindowState = xlMaximized Then
.Caption = ""
Else
.Caption = Name
End If
End With
End Sub

Of course, these go in the ThisWorkbook moduile.

If you are going to have other workbooks open at the same time and only want
this behavior for one of them, you will have to add similar code to the
Activate and Deactivate events for the workbook as well. Also, if you want
to get really sophisticated, check out John Walkenbach's site for what to do
to prevent the BeforeClose event from firing if the user changes his/her
mind and does not close the workbook.

http://j-walk.com/ss/excel/tips/tip78.htm

Regards,

Vasant.
 
Back
Top