Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Admin
 
Posts: n/a
Default How do I insert a partial filename?

I am inserting a filename to my footer; however the file path is very long
and I wanted to condense the file name by only showing the last 2-3 "folder
tiers". Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Cone
 
Posts: n/a
Default How do I insert a partial filename?

A,
Using code is the only way I know to do it.
Jim Cone
San Francisco, USA

'--------------------------
Sub FillInFooter()
Dim strPath As String
Dim strFooter As String
'Number of folders to display in footer.
Const lngNUMBER As Long = 2
strPath = ActiveWorkbook.FullName
'Call the function that parses the file path.
strFooter = ShowPartOfPath(strPath, lngNUMBER)
'Add path to the right footer.
ActiveSheet.PageSetup.RightFooter = strFooter
End Sub

Function ShowPartOfPath(ByVal strPath As String, ByRef lngFolders As Long)
'Jim Cone - San Francisco, USA - 11/30/2005
Dim lngCount As Long
Dim lngItem As Long
Const strCHAR As String = "\"
'Determine number of "\" in the file path.
lngCount = Len(strPath) - Len(Application.Substitute(strPath, strCHAR, vbNullString))
'If file path has more than the desired number of folders then proceed.
If lngCount lngFolders Then
lngItem = lngCount - lngFolders
lngCount = 0
'Loop thru filepath until correct "\" is found.
Do While lngItem 0
lngCount = InStr(lngCount + 1, strPath, strCHAR, vbTextCompare)
lngItem = lngItem - 1
Loop
strPath = "..." & Right$(strPath, Len(strPath) - lngCount)
End If
ShowPartOfPath = strPath
End Function
'--------------------------


"Admin"
wrote in message

I am inserting a filename to my footer; however the file path is very long
and I wanted to condense the file name by only showing the last 2-3 "folder
tiers". Any ideas?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
filename pointer tanhs Excel Worksheet Functions 0 June 21st 05 02:09 AM
Filename at the very top of Microsoft Excel Window Skyking Excel Discussion (Misc queries) 2 April 28th 05 04:25 AM
insert picture BillGwyer Excel Discussion (Misc queries) 1 March 4th 05 06:37 PM
Insert value of a cell as a filename Ralph Howarth Excel Worksheet Functions 0 January 18th 05 12:03 AM
Challenging Charting C TO Charts and Charting in Excel 0 January 17th 05 06:57 PM


All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"