Full path in title bar

N

ntoze

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top