I followed
http://wordtips.vitalnews.com/Pages/T0876_Full_Path_Names_in_Word.html
to get the full path of my documents in the title bar. The path is
quite long, so I only see the head of it, not the tail. That means I
often don't see the actual file name, nor the containing directory, or
parent directories. Even more problematic is that the corresponding
box in the taskbar shows only the first few characters of the path
i.e. "c:\AbC...".
Thanks!
Here's a revision of the macro from that article that will show only
enough of the tail of the file path to fit the maximum number of
characters (which you can specify by setting the value of maxLen near
the top of the macro).
Public Sub WindowTitleWithPath()
' Changes window title to include path with filename
Dim NameArray As Variant
Dim NameStringL As String
Dim NameStringR As String
Dim Count As Long
Const maxLen = 100 ' set this value to fit your window width
' Check if any child windows open
' (avoid error if no active window)
If Windows.Count > 0 Then
NameStringL = ActiveDocument.FullName
If Len(NameStringL) > maxLen Then
' separate the folder names
NameArray = Split(NameStringL, "\")
' check the folder depth
Count = UBound(NameArray)
If Count > 3 Then
NameStringL = NameArray(0) & "\...\"
NameStringR = NameArray(Count)
Count = Count - 1
' continue adding folders to the left of the string
' until you run out of folders or one won't fit
Do While (Count > 0) And _
(Len(NameStringL) + Len(NameStringR) + _
Len(NameArray(Count)) < maxLen)
NameStringR = NameArray(Count) & "\" _
& NameStringR
Count = Count - 1
Loop
NameStringL = NameStringL & NameStringR
End If
End If
' Change the window's caption
ActiveWindow.Caption = NameStringL
End If
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.