Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
filename pointer | Excel Worksheet Functions | |||
Filename at the very top of Microsoft Excel Window | Excel Discussion (Misc queries) | |||
insert picture | Excel Discussion (Misc queries) | |||
Insert value of a cell as a filename | Excel Worksheet Functions | |||
Challenging Charting | Charts and Charting in Excel |