#1
|
||||
|
||||
Separating path from file name
I would like to put the path on one line and the filename on a separate line in the footer. In Excel, it easy "&[Path]" on one line, "&[File]" on the next. But this doesn't work in Word and the out of the box options are filename alone and full path with filename. Can anyone tell me how to to show the path, without the filename? Thanks for your help! KBo
Last edited by Charles Kenyon; 03-13-2015 at 06:08 PM. Reason: Mark as solved |
#2
|
||||
|
||||
You cannot insert part of a field, but you can insert the path and filename on two lines with a macro e.g.
Code:
Sub InsertPathAndFilename() With ActiveDocument If Len(.Path) = 0 Then .Save Selection.TypeText .Path & Chr(92) & vbCr & .name End With lbl_Exit: Exit Sub End Sub Code:
& .name Code:
& Left(.name, InStrRev(.name, ".") - 1)
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
||||
|
||||
gmayor - Thank you, thank you, thank you!!! Works great! I have an additional request, however... Is it possible to add code that will convert all characters to lower case? KBo
|
#4
|
||||
|
||||
Wrap the text in brackets and prefix with LCase e.g.
Code:
Selection.TypeText LCase(.Path & Chr(92) & vbCr & .name)
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
||||
|
||||
Thanks, Graham! Do you know how to put the "Solved" graphic in the subject line??? Thanks again for your help!! KBo
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Publisher '07--default file path | markg2 | Publisher | 0 | 02-15-2014 10:22 AM |
Quickly add file path name to footer | nimblewit | Word | 2 | 05-03-2013 05:17 AM |
Relative path to a video file | dedine | PowerPoint | 3 | 01-31-2013 12:55 PM |
File Path for Outlook 2007 pst | eliz.bell | Outlook | 2 | 10-29-2011 07:04 PM |
get file name without Path | Ziggy1 | Word VBA | 1 | 09-29-2006 07:55 PM |