View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Vasant Nanavati Vasant Nanavati is offline
external usenet poster
 
Posts: 1,080
Default changing the application name in the title bar

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.


"Paul James" wrote in message
...
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?