FILENAME Field

  • Thread starter koala824 at Comcast
  • Start date
K

koala824 at Comcast

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
 
S

Suzanne S. Barnhill

This is a Windows setting. If you have extensions displayed in Windows, they
will be in Word as well.
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top