Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I change footer to only show 1 level of path and file name
I want to put footer on a document (word and excel) but I only want to show
one level of the path and file name. ex: C:\...\folder\file name. The choices in the list only give path and file or file name. Path and file name is too long. Ex: C:\Documents and Settings\Owner\My Documents\folder name\file name. C:\folder name\file name is sufficient. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I change footer to only show 1 level of path and file name
Hi ?B?Um9zZSBN?=,
I want to put footer on a document (word and excel) but I only want to show one level of the path and file name. ex: C:\...\folder\file name. The choices in the list only give path and file or file name. Path and file name is too long. Ex: C:\Documents and Settings\Owner\My Documents\folder name\file name. C:\folder name\file name is sufficient. there is no built-in option for what you want. You'd need to use a macro solution, which could get a bit complicated if the path needs to update whenever the document is opened and/or saved. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I change footer to only show 1 level of path and file name
If the problem is that the full path takes up too much space in your
footer, you could simply decrease the font size of the Footer paragraph style. Alternatively, you can use the macro below which provides a semi-automatic way to create paths of the type "C:\..\folder\filename". The macro creates a document variable named CustomPath (if necessary). If a file has been moved to a different location, just run the macro again to update the value of CustomPath. To display the value of CustomPath in your document you would use the field { DOCVARIABLE "CustomPath" }. To insert this field, press CTRL+F9, type DOCVARIABLE "CustomPath" between the field delimiters, and press F9. After you've updated the value of the doc variable (by using the macro), you can switch to Print Preview which will force an update of the field. Sub DetermineCustomPath Dim FullPath As String, Temp As String Dim Pos1 As Long, Pos2 As Long Dim RootFolder As String Dim TheResult As String Dim v As Variable FullPath = ActiveDocument.Path Pos1 = InStr(FullPath, "\") RootFolder = Left(FullPath, Pos1) Temp = StrReverse(FullPath) Pos2 = InStr(Temp, "\") TheResult = Right(FullPath, Pos2) For Each v In ActiveDocument.Variables If v.Name = "CustomPath" Then v.Value = RootFolder & ".." & TheResult & "\" & _ ActiveDocument.Name Exit Sub End If Next v ActiveDocument.Variables.Add "CustomPath", RootFolder & ".." & _ TheResult & "\" & ActiveDocument.Name End Sub -- Stefan Blom Microsoft Word MVP "Rose M" wrote in messsage ... I want to put footer on a document (word and excel) but I only want to show one level of the path and file name. ex: C:\...\folder\file name. The choices in the list only give path and file or file name. Path and file name is too long. Ex: C:\Documents and Settings\Owner\My Documents\folder name\file name. C:\folder name\file name is sufficient. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I change footer to only show 1 level of path and file name
Hmm, I just realized that the code in my previous reply doesn't
consider the case when a file is located in a root folder, such as C:\. The code below does, which improves things a bit (but there are other special situations that should be taken care of). Note: If you need help with installing the macro, see: http://gmayor.com/installing_macro.htm. 'Modified code example: Sub DetermineCustomPath2 Dim FullPath As String, Temp As String Dim Pos1 As Long, Pos2 As Long Dim RootFolder As String Dim TheResult As String Dim v As Variable FullPath = ActiveDocument.Path Pos1 = InStr(FullPath, "\") If Pos1 = 0 Then TheResult = ActiveDocument.FullName Else RootFolder = Left(FullPath, Pos1) Temp = StrReverse(FullPath) Pos2 = InStr(Temp, "\") TheResult = Right(FullPath, Pos2) TheResult = RootFolder & ".." & TheResult & "\" & _ ActiveDocument.Name End If For Each v In ActiveDocument.Variables If v.Name = "CustomPath" Then v.Value = TheResult Exit Sub End If Next v ActiveDocument.Variables.Add "CustomPath", TheResult End Sub -- Stefan Blom Microsoft Word MVP "Stefan Blom" skrev i meddelandet ... If the problem is that the full path takes up too much space in your footer, you could simply decrease the font size of the Footer paragraph style. Alternatively, you can use the macro below which provides a semi-automatic way to create paths of the type "C:\..\folder\filename". The macro creates a document variable named CustomPath (if necessary). If a file has been moved to a different location, just run the macro again to update the value of CustomPath. To display the value of CustomPath in your document you would use the field { DOCVARIABLE "CustomPath" }. To insert this field, press CTRL+F9, type DOCVARIABLE "CustomPath" between the field delimiters, and press F9. After you've updated the value of the doc variable (by using the macro), you can switch to Print Preview which will force an update of the field. Sub DetermineCustomPath Dim FullPath As String, Temp As String Dim Pos1 As Long, Pos2 As Long Dim RootFolder As String Dim TheResult As String Dim v As Variable FullPath = ActiveDocument.Path Pos1 = InStr(FullPath, "\") RootFolder = Left(FullPath, Pos1) Temp = StrReverse(FullPath) Pos2 = InStr(Temp, "\") TheResult = Right(FullPath, Pos2) For Each v In ActiveDocument.Variables If v.Name = "CustomPath" Then v.Value = RootFolder & ".." & TheResult & "\" & _ ActiveDocument.Name Exit Sub End If Next v ActiveDocument.Variables.Add "CustomPath", RootFolder & ".." & _ TheResult & "\" & ActiveDocument.Name End Sub -- Stefan Blom Microsoft Word MVP "Rose M" wrote in messsage ... I want to put footer on a document (word and excel) but I only want to show one level of the path and file name. ex: C:\...\folder\file name. The choices in the list only give path and file or file name. Path and file name is too long. Ex: C:\Documents and Settings\Owner\My Documents\folder name\file name. C:\folder name\file name is sufficient. |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I change footer to only show 1 level of path and file name
My fellow MVPs have offered solutions based on what you have, but don't
overlook the obvious. Move your Word documents folder to a folder directly off the root eg C:\Foldername (Tools options file locations Documents) and you won't have a long path to deal with -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Rose M wrote: I want to put footer on a document (word and excel) but I only want to show one level of the path and file name. ex: C:\...\folder\file name. The choices in the list only give path and file or file name. Path and file name is too long. Ex: C:\Documents and Settings\Owner\My Documents\folder name\file name. C:\folder name\file name is sufficient. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
File path of sub in footer of master | Formatting Long Documents | |||
How to creat relative and shorthand file path names? | Microsoft Word Help | |||
Adding the path and file name to the footer of my Normal.dot and . | Microsoft Word Help | |||
Possible to set up default footer with file and path name? | Page Layout | |||
file name and path footer? | Microsoft Word Help |