Full Pathname in Titlebar

G

Greg

How do I display a filename's full pathname in the titlebar (i.e. "c:\my
documents\filename" instead of just "filename").
 
G

Gord Dibben

Greg

No setting, but code.......copy/paste the code below into the ThisWorkbook
Module of your workbook.

Private Sub Workbook_Open()
ActiveWindow.Caption = ActiveWorkbook.FullName
End Sub

Right-click on the Excel logo at top left of Menubar and select "View Code".

Paste in there.

Save the workbook.

OR....use this Toggle macro.

Sub CaptionToggle()
' toggles title bar between document name and full path
If ActiveWindow.Caption = ActiveWorkbook.Name Then
ActiveWindow.Caption = ActiveWorkbook.FullName
Else: ActiveWindow.Caption = ActiveWorkbook.Name
End If
End Sub


Gord Dibben Excel MVP
 
D

David McRitchie

I used to use Auto_Open for this and I know it interfered
with me in some way. In any I'd rather have a shorter
name that is correct than a full pathname that is incorrect.

If you have two workbooks open as you switch between them
one of them will be incorrectly marked on the title bar if you
are viewing the spreadsheet maximized within the Excel window.

The following will work better and would be placed in "ThisWorkbook"

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
ActiveWindow.Caption = ActiveWorkbook.FullName
End Sub

I will change my pathname.htm web page to show the above
a a preference to Auto_Open. I tried using an deactivate as well
but it seemed to gain nothing. And the title bars of the worksheet when normal or whater not maximized is called then both had
their own correct pathnames regardless of which was active. (both title bars as well
as the Excel window titlebar all being visible)
 
D

Dave Peterson

David,

Bob Phillips and I had a recent thread discussing the same issue. We used an
application event (with references to both your and Chip Pearson's site!).

If you want to steal/modify any of the stuff we did, it's ok with me. I bet Bob
would say ok, too. (Heck it's on google, so he can't be too upset <bg>.)

http://groups.google.co.uk/[email protected]

(It's ok if you don't want to use any of it, too.)

David said:
I used to use Auto_Open for this and I know it interfered
with me in some way. In any I'd rather have a shorter
name that is correct than a full pathname that is incorrect.

If you have two workbooks open as you switch between them
one of them will be incorrectly marked on the title bar if you
are viewing the spreadsheet maximized within the Excel window.

The following will work better and would be placed in "ThisWorkbook"

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
ActiveWindow.Caption = ActiveWorkbook.FullName
End Sub

I will change my pathname.htm web page to show the above
a a preference to Auto_Open. I tried using an deactivate as well
but it seemed to gain nothing. And the title bars of the worksheet when normal or whater not maximized is called then both had
their own correct pathnames regardless of which was active. (both title bars as well
as the Excel window titlebar all being visible)
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

Gord Dibben said:
Greg

No setting, but code.......copy/paste the code below into the ThisWorkbook
Module of your workbook.

Private Sub Workbook_Open()
ActiveWindow.Caption = ActiveWorkbook.FullName
End Sub

Right-click on the Excel logo at top left of Menubar and select "View Code".

Paste in there.

Save the workbook.

OR....use this Toggle macro.

Sub CaptionToggle()
' toggles title bar between document name and full path
If ActiveWindow.Caption = ActiveWorkbook.Name Then
ActiveWindow.Caption = ActiveWorkbook.FullName
Else: ActiveWindow.Caption = ActiveWorkbook.Name
End If
End Sub


Gord Dibben Excel MVP
 

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