View Single Post
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom
 
Posts: n/a
Default 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.