Modifying AutoText in Word

K

Kevin E.

I want to insert the filename of my doc into the header or footer, but i
don't want the extension at the end of the text. How can I modify or create
an autotext to insert the text with out the ".doc" at the end? Any help or
suggestions are greatly appreciated, thanks.
 
S

Suzanne S. Barnhill

You can't. If extensions are displayed in Windows, they'll be displayed in
the FILENAME field, and vice versa. This is system-dependent.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
G

Graham Mayor

Suzanne is correct, you can't do this with autotext, but you can do it with
macros

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

OR

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

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