Thread: FILENAME Field
View Single Post
  #3   Report Post  
Posted to microsoft.public.word.pagelayout
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default FILENAME Field

If you want to retain the field then as Suzanne suggests you need to change
the Windows display of extensions, which will not help if others open the
document. In any case it is most helpful to display extensions in Windows,
so not that pratical. You can instead use a macro to insert the filename or
filename and path without extension eg

Sub InsertfNameAndPath()
Dim pPathname As String
With ActiveDocument
If Len(.Path) = 0 Then
.Save
End If
If Right(.name, 1) = "x" Then
pPathname = Left$(.FullName, (Len(.FullName) - 5))
Else
pPathname = Left$(.FullName, (Len(.FullName) - 4))
End If
End With
Selection.TypeText pPathname
End Sub

Sub InsertFnameOnly()
Dim pPathname As String
With ActiveDocument
If Len(.Path) = 0 Then
.Save
End If
If Right(.name, 1) = "x" Then
pPathname = Left$(.name, (Len(.name) - 5))
Else
pPathname = Left$(.name, (Len(.name) - 4))
End If
End With
Selection.TypeText pPathname
End Sub

and the following will type the filename without extension in the current
page header

Sub InsertFilenameinHeader()
Dim pPathname As String
With ActiveDocument
If Len(.Path) = 0 Then
.Save
End If
If Right(.name, 1) = "x" Then
pPathname = Left$(.name, (Len(.name) - 5))
Else
pPathname = Left$(.name, (Len(.name) - 4))
End If
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.TypeText pPathname
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

http://www.gmayor.com/installing_macro.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


koala824 at Comcast wrote:
Is there any way to use this field so that the filename that shows
does NOT include the file extension? I want to use the filename in my
header, but do not want the .DOC extension to show. Thanks