Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2015, 08:09 PM
KBo's Avatar
KBo KBo is offline Separating path from file name Windows 7 64bit Separating path from file name Office 2007
Novice
Separating path from file name
 
Join Date: Feb 2015
Posts: 3
KBo is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 02-22-2015, 10:51 PM
gmayor's Avatar
gmayor gmayor is offline Separating path from file name Windows 7 64bit Separating path from file name Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,103
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
If you want the name without the extension change
Code:
& .name
to
Code:
& Left(.name, InStrRev(.name, ".") - 1)
http://www.gmayor.com/installing_macro.htm
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 02-25-2015, 02:48 PM
KBo's Avatar
KBo KBo is offline Separating path from file name Windows 7 64bit Separating path from file name Office 2007
Novice
Separating path from file name
 
Join Date: Feb 2015
Posts: 3
KBo is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 02-25-2015, 10:51 PM
gmayor's Avatar
gmayor gmayor is offline Separating path from file name Windows 7 64bit Separating path from file name Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,103
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #5  
Old 03-11-2015, 01:45 PM
KBo's Avatar
KBo KBo is offline Separating path from file name Windows 7 64bit Separating path from file name Office 2007
Novice
Separating path from file name
 
Join Date: Feb 2015
Posts: 3
KBo is on a distinguished road
Default

Thanks, Graham! Do you know how to put the "Solved" graphic in the subject line??? Thanks again for your help!! KBo
Reply With Quote
Reply



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
Separating path from file name Relative path to a video file dedine PowerPoint 3 01-31-2013 12:55 PM
Separating path from file name File Path for Outlook 2007 pst eliz.bell Outlook 2 10-29-2011 07:04 PM
Separating path from file name get file name without Path Ziggy1 Word VBA 1 09-29-2006 07:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft