ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Full path in title bar (https://www.excelbanter.com/excel-discussion-misc-queries/73046-full-path-title-bar.html)

ntoze

Full path in title bar
 
This seems to me a good way to do it.

In a new workbook, create a class named AppEvents and put the following
code in it:

Option Explicit

Public WithEvents App As Application

Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
showFullName Wb
End Sub

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook,
ByVal SaveAsUI As Boolean, Cancel As Boolean)
Static inEvent As Boolean

If SaveAsUI Then
If inEvent Then
Exit Sub
End If
inEvent = True

Application.Dialogs(xlDialogSaveAs).Show
showFullName ActiveWorkbook

Cancel = True
inEvent = False
End If
End Sub

Private Sub showFullName(Wb As Workbook)
Dim caption As String
On Error Resume Next

caption = Wb.FullName
' There doesn't seem to be an event for toggling read-only,
' so I think it is better to not display this rather
' than deceive.
' If Wb.ReadOnly Then
' caption = caption & " [Read-Only]"
' End If

Wb.Windows(1).caption = caption
End Sub


Then add a module and put this in:

Dim x As New AppEvents

Public Sub Auto_Open()
Set x.App = Application
End Sub


Then compile and save the workbook as an xla.

Then include it in Tools-Add Ins.



All times are GMT +1. The time now is 01:09 AM.

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